transparent pixels

How can I mask one color in an <code> Image </code>to appear transparent?I need to draw one image above another, with only the significant areas shown.
[177 byte] By [Aikmana] at [2007-9-28 11:47:09]
# 1
Read the api about java.awt.image.*, there's probably some class you can use.
Kayamana at 2007-7-12 2:36:15 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 2

You can use a RBGImageFilter to act upon the alpha component for some predefined color:

// the original image

Image original = ...;

// the RGB code of the color to turn into "transparent"

inttransparentColor = ...;

// the resulting image

Image transparent

= createImage(

new FilteredImageSource(

original.getSource(),

new RGBImageFilter() {

{ canFilterIndexColorModel = true; }

public int filterRGB(int x, int y, int rgb) {

if (rgb==transparentColor) {

return 0x000000ff;

} else {

return rgb;

}

}

}

)

);

remistigria at 2007-7-12 2:36:15 > top of Java-index,Archived Forums,New To Java Technology Archive...
# 3
I am now using a GIF with transparent BG. THX anyway. I will use this next time.
Aikmana at 2007-7-12 2:36:15 > top of Java-index,Archived Forums,New To Java Technology Archive...