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;
}
}
}
)
);