jai image overlay
Posted on 2002-04-18
I am trying to dynamically watermark an image, so that it can be served via an applet.
I will be starting with a tiff image, that I would like to overlay a water mark with "sample" over the original image.
I have been experimenting with gif imagages to start with and have thought about using a transparent gif image; the watermark with JAI.create("overlay",src1,src2) to create the output RenderedImage.
The problem I am having with this, is that when I create a RenderedImage based on the transparent gif file, it is not decoding it properly, thus the resulting image is simply all black.
i'm not sure how to decode/encode the images properly and the following code is my attempt at opening, combining and saving images:
public RenderedImage im1;
public RenderedImage im2;
public RenderedImage im3;
private final String baseImFile = "base.gif";
private final String waterImFile = "trans.gif";
im1 = JAI.create("fileload",baseImFile);
im2 = JAI.create("fileload",waterImFile);
im3 = JAI.create("overlay",im1,im2);
How can I encode/decode the images properly to get the resulting image I'm after?
Once I get this to work, can i use a "base" tiff image with a "transparent" gif overlay? If not, any clues on how I go about this?