166 |
setIconImage(frame.getIconImage()); |
setIconImage(frame.getIconImage()); |
167 |
} |
} |
168 |
|
|
169 |
native void nativeSetIconImageFromDecoder (GdkPixbufDecoder decoder); |
native void nativeSetIconImage (GtkImage image); |
170 |
native void nativeSetIconImageFromData (int[] pixels, int width, int height); |
|
171 |
public void setIconImage (Image image) |
public void setIconImage (Image image) |
172 |
{ |
{ |
173 |
if (image != null && image instanceof GtkImage) |
if (image != null) |
174 |
{ |
{ |
175 |
GtkImage img = (GtkImage) image; |
if (image instanceof GtkImage) |
176 |
// FIXME: Image should be loaded, but if not, do image loading here. |
nativeSetIconImage((GtkImage) image); |
177 |
if (img.isLoaded()) |
else |
178 |
{ |
nativeSetIconImage(new GtkImage(image.getSource())); |
179 |
if (img.getSource() instanceof GdkPixbufDecoder) |
} |
|
{ |
|
|
nativeSetIconImageFromDecoder((GdkPixbufDecoder) img.getSource()); |
|
|
} |
|
|
else |
|
|
{ |
|
|
int[] pixels = img.getPixelCache(); |
|
|
ColorModel model = img.getColorModel(); |
|
|
int[] data = new int[pixels.length * 4]; |
|
|
for (int i = 0; i < pixels.length; i++) |
|
|
{ |
|
|
data[i * 4] = model.getRed(pixels[i]); |
|
|
data[i * 4 + 1] = model.getGreen(pixels[i]); |
|
|
data[i * 4 + 2] = model.getBlue(pixels[i]); |
|
|
data[i * 4 + 3] = model.getAlpha(pixels[i]); |
|
|
} |
|
|
nativeSetIconImageFromData(data, img.getWidth(null), img.getHeight(null)); |
|
|
} |
|
|
} |
|
|
} |
|
180 |
} |
} |
181 |
|
|
182 |
public Graphics getGraphics () |
public Graphics getGraphics () |