1 30 31 package com.caucho.graphics; 32 33 import java.awt.*; 34 import java.awt.image.ColorModel ; 35 import java.awt.image.ImageConsumer ; 36 import java.util.Hashtable ; 37 38 public class Images implements ImageConsumer { 39 private static Toolkit toolkit; 40 private int width; 41 private int height; 42 43 public static Images getImage(String filename) 44 { 45 try { 46 if (toolkit == null) 47 toolkit = Toolkit.getDefaultToolkit(); 48 49 Image img = toolkit.getImage(filename); 50 51 if (img == null) 52 return null; 53 54 Images image = new Images(); 55 56 img.getSource().startProduction(image); 57 58 synchronized (image) { 59 image.wait(100); 60 } 61 62 if (image.width > 0 && image.height > 0) 63 return image; 64 else 65 return null; 66 } catch (Throwable e) { 67 return null; 68 } 69 } 70 71 public int getWidth() 72 { 73 return width; 74 } 75 76 public int getHeight() 77 { 78 return height; 79 } 80 81 public void imageComplete(int status) 82 { 83 synchronized (this) { 84 this.notifyAll(); 85 } 86 } 87 public void setColorModel(ColorModel model) {} 88 89 public void setDimensions(int width, int height) 90 { 91 this.width = width; 92 this.height = height; 93 } 94 95 public void setHints(int hintflags) {} 96 public void setPixels(int x, int y, int w, int h, ColorModel mode, 97 byte []pixels, int off, int scansize) {} 98 public void setPixels(int x, int y, int w, int h, ColorModel mode, 99 int []pixels, int off, int scansize) {} 100 101 public void setProperties(Hashtable <?,?> props) {} 102 } 103 104 105 | Popular Tags |