[JAI] GIF images corrupt?
I previously posted regarding the performance of taking a huge (200meg)
TIFF image, cropping, scaling, and then writing it out as a JPEG.
I asked the forum about possibiliies for speeding things up. Since
most of the time seemed to be spent in the encoding of the JPEG,
someone suggested encoding into a simpler format - e.g. TIFF or GIF.
But when I tried to encode to GIF, my firefox browser prints the
The image "http://localhost:8084/ja/ImageServer?imgType=gif..."
cannot be displayed, because it contains errors.
In IE, I just see the IE "placeholder" icon for the image.
I'm using the following code to do the encoding - I don't see how I
can be doing anything wrong here - especially when it works for the
other image formats (JPEG, PNG, and TIFF) I've tried:
workingImage = JAI.create("stream", stream);
ServletOutputStream out = response.getOutputStream();
...set parameter block for cropping...
workingImage = JAI.create("crop", pb);
...set parameter block for scaling...
workingImage = JAI.create("scale", pb);
javax.imageio.ImageIO.write(workingImage, "gif", out);
Does anyone have any clue why this could be happening? Many thanks for
P.S. Environment: JDK 1.4.2, Tomcat 5.5.7, JAI 1.1.2_01, and JIO 1.0_01
running on Windows XP.
P.P.S. Do I need to worry about synchronization between the scaling operation
and the final rendering? In the other thread on performance, I mentioned that
scaling appears to take less than a millisecond when I print out the time
before/after the operation. James Cheng observed that the rendering might
have been defered?? If that's the case, perhaps I need to wait with the
final encoding until scaling is done? How is this done? I'm a JAI novice.