View Single Post
  #3 (permalink)  
Old 12-09-2007, 07:07 PM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,266
hardwired is on a distinguished road
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
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; }
which you can find in your sdk (1.5) at:
sdk1.5/src/com/sun/java/swing/plaf/windows/XPStyle
Reply With Quote