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) |
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.
00082 {
00083 super(Converter.ICS_ORIGIN, Converter.ICS_ORIGIN, 0., 0.);
00084
00085 File imFile = new File(filename);
00086 if (!(imFile.exists() && imFile.canRead()))
00087 return;
00088
00089 Image im = comp.getToolkit().getImage(filename);
00090 MediaTracker t = new MediaTracker(comp);
00091 t.addImage(im, 0);
00092 try {
00093 t.waitForAll();
00094 } catch (InterruptedException e) {
00095 return;
00096 }
00097 if (im == null)
00098 return;
00099
00100 setImageDim(im.getWidth(null), im.getHeight(null));
00101 initImage(im);
00102 }
|
|
|
Draw CanvasObject on 'g', using internal CCS values.
Reimplemented from CanvasObject.
00106 {
00107 setupDrawMode(g);
00108 if (!getTransformOK()) {
00109 transformICStoCCS();
00110 }
00111 if (DEBUG_OBJECTS) {
00112 OutputStreamArea.println("Draw JavaImage called, image w: " + _bufIm.getWidth(null) +
00113 ", h: " + _bufIm.getHeight(null));
00114 dump();
00115 }
00116 if (_bufIm != null)
00117 g.drawImage(_bufIm, getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs(), null);
00118 else
00119 g.drawImage(_im, getX1Ccs(), getY1Ccs(), getWidthCcs(), getHeightCcs(), null);
00120 }
|
|
||||||||||||
|
00134 {
00135 return (new Color(_bufIm.getRGB(x, y)));
00136 }
|
|
||||||||||||||||
|
Reimplemented from CanvasImage.
00140 {
00141 _bufIm.setRGB(x, y, c.getRGB());
00142 }
|
|
||||||||||||||||||||
|
00146 {
00147 return _bufIm.getRGB(x, y, w, h, null, 0, w);
00148 }
|
|
||||||||||||||||||||
|
Reimplemented from CanvasImage.
00152 {
00153 return _bufIm.getSubimage(x, y, w, h);
00154 }
|
|
||||||||||||||||||||
|
Reimplemented from CanvasImage.
00158 {
00159 String[] strs = new String[w*h];
00160 int imWidth = _bufIm.getWidth();
00161 int imHeight = _bufIm.getHeight();
00162 for (int i=0; i<w; i++) {
00163 for (int j=0; j<h; j++) {
00164 if (x+i < 0 || y+j < 0 || x+i >= imWidth || y+j >= imHeight) {
00165 strs[i+j*w] = new String("");
00166 } else {
00167 int pix = _bufIm.getRGB(x+i, y+j);
00168 Color c = new Color(pix);
00169 strs[i+j*w] = HX.colorToString(c);
00170 }
00171 }
00172 }
00173 return strs;
00174 }
|
|
|
00185 {
00186 if (im instanceof BufferedImage) {
00187 _bufIm = (BufferedImage) im;
00188 return;
00189 }
00190 _bufIm = null;
00191 _im = im;
00192 /*
00193 int w = im.getWidth(null);
00194 int h = im.getHeight(null);
00195 int[] pixels = new int[w*h];
00196 PixelGrabber pg =
00197 new PixelGrabber(im, 0, 0, w, h, pixels, 0, w);
00198 try {
00199 pg.grabPixels();
00200 } catch (InterruptedException e) {
00201 return;
00202 }
00203 if ((pg.getStatus() & ImageObserver.ABORT) != 0)
00204 return;
00205
00206 _bufIm = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
00207 _bufIm.setRGB(0, 0, w, h, pixels, 0, w);
00208 */
00209 }
|
|
||||||||||||
|
00213 {
00214 _bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
00215 }
|
|
||||||||||||||||
|
00219 {
00220 _bufIm = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
00221 _bufIm.setRGB(0, 0, width, height, pixels, 0, width);
00222 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001