Java 2D - Image with transparent polygon.
Hello,
I am trying to overlay one image with another.
The image on top must be altered so part of it (say upper left corner)
is transparent, in order for the image on the bottom to show up in this location.
I am using the JAI.create ("overlay", ...);
This part works fine, what I cannot do is creating the top image with parts of it transparent.
I tried to use ROIShape but it allows only one-band images, and my images have 3 bands (they are jpegs)
The image part I need to make transparent is not rectangular-it's a polygon (triangle)
I would appreciate any hints.
Thanks
-Tom
[646 byte] By [
skifracea] at [2007-11-26 23:23:53]

# 1
I Have a method to make a colour in a image trsparent if thats any help:
public static BufferedImage makeColorTransparent(BufferedImage in,final Color color)
{
ImageFilter filter = new RGBImageFilter()
{
// the color we are looking for... Alpha bits are set to opaque
public int markerRGB = color.getRGB() | 0xFF000000;
public final int filterRGB(int x, int y, int rgb)
{
if ((rgb|0xFF000000)==markerRGB)
{
// Mark the alpha bits as zero - transparent
return 0x00FFFFFF & rgb;
}
else
{
// nothing to do
return rgb;
}
}
};
ImageProducer ip = new FilteredImageSource(in.getSource(), filter);
return (BufferedImage)Toolkit.getDefaultToolkit().createImage(ip);
}