Inheritance diagram for CanvasJavaImage::
Public Methods | |
CanvasJavaImage () | |
Construct an empty image. More... | |
CanvasJavaImage (int width, int height) | |
Construct an empty image. More... | |
CanvasJavaImage (Image im) | |
Construct from a Java Image. More... | |
CanvasJavaImage (BufferedImage im) | |
Construct from a buffered Java Image. More... | |
CanvasJavaImage (int[] pixels, double w, double h) | |
Construct from a set of RGB pixels. More... | |
CanvasJavaImage (String filename, Component comp) | |
Construct from a file. More... | |
void | draw (Graphics g) |
Draw CanvasObject on 'g', using internal CCS values. More... | |
Color | getPixel (int x, int y) |
void | setPixel (int x, int y, Color c) |
int[] | getPixels (int x, int y, int w, int h) |
BufferedImage | getSubImage (int x, int y, int w, int h) |
String[] | getPixelStrings (int x, int y, int w, int h) |
void | moveImage (double x, double y) |
Moves the image to the (x,y) position, keeping current properties. More... | |
Protected Methods | |
void | initImage (Image im) |
void | initImage (int width, int height) |
void | initImage (int[] pixels, int width, int height) |
The sizes of the java image determine the sizes (in ICS) of the CanvasHxImage. The draw method of this class actually draws _bufIm at the CCS coordinates. So, Graphics.drawImage does the actual zooming of the pixel data.
|
Construct an empty image.
|
|
Construct an empty image.
|
|
Construct from a Java Image.
|
|
Construct from a buffered Java Image.
|
|
Construct from a set of RGB pixels.
|
|
Construct from a file. comp is used to get at the ToolKit.
00086 { 00087 super(Converter.ICS_ORIGIN, Converter.ICS_ORIGIN, 0., 0.); 00088 00089 File imFile = new File(filename); 00090 if (!(imFile.exists() && imFile.canRead())) 00091 return; 00092 00093 Image im = comp.getToolkit().getImage(filename); 00094 MediaTracker t = new MediaTracker(comp); 00095 t.addImage(im, 0); 00096 try { 00097 t.waitForAll(); 00098 } catch (InterruptedException e) { 00099 return; 00100 } 00101 if (im == null) 00102 return; 00103 00104 setImageDim(im.getWidth(null), im.getHeight(null)); 00105 initImage(im); 00106 } |
|
Draw CanvasObject on 'g', using internal CCS values.
Reimplemented from CanvasObject.
00110 { 00111 setupDrawMode(g); 00112 if (!getTransformOK()) { 00113 transformICStoCCS(); 00114 } 00115 if (DEBUG_OBJECTS) { 00116 OutputStreamArea.println("Draw JavaImage called, image w: " + _bufIm.getWidth(null) + 00117 ", h: " + _bufIm.getHeight(null)); 00118 dump(); 00119 } 00120 if (_bufIm != null) 00121 g.drawImage(_bufIm, getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs(), null); 00122 else 00123 g.drawImage(_im, getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs(), null); 00124 } |
|
00138 { 00139 return (new Color(_bufIm.getRGB(x, y))); 00140 } |
|
Reimplemented from CanvasImage.
00144 { 00145 _bufIm.setRGB(x, y, c.getRGB()); 00146 } |
|
00150 { 00151 return _bufIm.getRGB(x, y, w, h, null, 0, w); 00152 } |
|
Reimplemented from CanvasImage.
00156 { 00157 return _bufIm.getSubimage(x, y, w, h); 00158 } |
|
Reimplemented from CanvasImage.
00162 { 00163 String[] strs = new String[w*h]; 00164 int imWidth = _bufIm.getWidth(); 00165 int imHeight = _bufIm.getHeight(); 00166 for (int i=0; i<w; i++) { 00167 for (int j=0; j<h; j++) { 00168 if (x+i < 0 || y+j < 0 || x+i >= imWidth || y+j >= imHeight) { 00169 strs[i+j*w] = new String(""); 00170 } else { 00171 int pix = _bufIm.getRGB(x+i, y+j); 00172 Color c = new Color(pix); 00173 strs[i+j*w] = HX.colorToString(c); 00174 } 00175 } 00176 } 00177 return strs; 00178 } |
|
Moves the image to the (x,y) position, keeping current properties.
Reimplemented from CanvasImage.
00183 { 00184 setImageDim(x, y, getWidth(), getHeight(), getZoomFactor()); 00185 } |
|
00195 { 00196 if (im instanceof BufferedImage) { 00197 _bufIm = (BufferedImage) im; 00198 return; 00199 } 00200 _bufIm = null; 00201 _im = im; 00202 /* 00203 int w = im.getWidth(null); 00204 int h = im.getHeight(null); 00205 int[] pixels = new int[w*h]; 00206 PixelGrabber pg = 00207 new PixelGrabber(im, 0, 0, w, h, pixels, 0, w); 00208 try { 00209 pg.grabPixels(); 00210 } catch (InterruptedException e) { 00211 return; 00212 } 00213 if ((pg.getStatus() & ImageObserver.ABORT) != 0) 00214 return; 00215 00216 _bufIm = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); 00217 _bufIm.setRGB(0, 0, w, h, pixels, 0, w); 00218 */ 00219 } |
|
00223 { 00224 _bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 00225 } |
|
00229 { 00230 _bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 00231 _bufIm.setRGB(0, 0, width, height, pixels, 0, width); 00232 } |