How do I removed the white part of images in label?
Printable View
How do I removed the white part of images in label?
The easiest way is to use a GIF-image.
removed the white part of images in label
Do you mean how to remove the color white from an image? You use something like this
which you can find in your sdk (1.5) at:Code:private BufferedImage convertToTransparent(BufferedImage src,
Color transparentColor) {
int w = src.getWidth();
int h = src.getHeight();
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsConfiguration gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
BufferedImage dest = gc.createCompatibleImage(w, h, Transparency.BITMASK);
int trgb;
if (transparentColor != null) {
trgb = transparentColor.getRGB() | 0xff000000;
} else {
trgb = 0xffff00ff;
}
// Copy pixels a scan line at a time
int buf[] = new int[w];
for (int y = 0; y < h; y++) {
src.getRGB(0, y, w, 1, buf, 0, w);
for (int x = 0; x < w; x++) {
if (buf[x] == trgb) {
buf[x] = 0;
}
}
dest.setRGB(0, y, w, 1, buf, 0, w);
}
return dest;
}
sdk1.5/src/com/sun/java/swing/plaf/windows/XPStyle
What does
label.setOpaque
do?