GenerateImagepublic class GenerateImage extends Object
Fields Summary |
---|
private IndexColorModel | icm | private DirectColorModel | dcm | private Image | image | private byte[] | data | private int | width | private int | height | byte[] | reds | byte[] | greens | byte[] | blues |
Constructors Summary |
---|
public GenerateImage()
int ncolors = getColors(reds, 0);
getColors(greens, 1);
getColors(blues, 2);
icm = new IndexColorModel(8, 256, reds, greens, blues, 0);
|
Methods Summary |
---|
protected synchronized void | createBuffer(int w, int h)
width = w;
height = h;
data = new byte[w * h];
| protected synchronized void | createImage()
MemoryImageSource mis = new MemoryImageSource(width, height,
icm, data, 0, width);
Toolkit tk = Toolkit.getDefaultToolkit();
image = tk.createImage(mis);
tk.prepareImage(image, width, height, null);
| private native boolean | generateImage(java.lang.String imageName)
| private native int | getColors(byte[] colors, int component)
| public java.awt.Image | getImage(java.lang.String imageName)
image = null;
data = null;
if (generateImage(imageName)) {
createImage();
return image;
} else
return null;
|
|