Details
-
Bug
-
Status: Resolved
-
Resolution: Fixed
-
1.2
-
None
-
None
-
Operating System: other
Platform: Other
Description
The following snippet does not work because the parameters are not created
correctly.
To be precise:
1. Define imageParameters with "JPEG" set as encoding
2. TiffImageWriter#createTIFFEncodeParams(lines 60++) will NOT call
setJPEGEncodeParam
3. Eventually TiffImageEncoder gets called and in line 467ff a call to
TIFFEncodeParam#getJPEGEncodeParam() is done, which returns null => NPE in line
472 int maxSubH = jep.getHorizontalSubsampling(0);
The whole class TiffImageWriter seems untested because if i look at the source i
see in line 46 the method public void writeImage(RenderedImage image,
OutputStream out) which passes null to as ImageWriterParams to 54:public void
writeImage(RenderedImage image, OutputStream out,ImageWriterParams params)
throws IOException , which in turn passed null to 61: private
TIFFEncodeParam createTIFFEncodeParams(ImageWriterParams params).
First statement in that method is if (params.getCompressionMethod() == null) ,
so you will get NPE here too...
org.apache.xmlgraphics.image.writer.ImageWriter imageWriter = new
TIFFImageWriter();
MultiImageWriter writer = null;
try
{
writer = imageWriter.createMultiImageWriter(stream);
// retrieve writer
if (imageWriter != null)
{
log.info("get image writers parameters");
ImageWriterParams iwp = new ImageWriterParams();
iwp.setCompressionMethod("JPEG");
iwp.setJPEGQuality(compressionQuality, true);
iwp.setResolution(param.getDpi());
log.info("render pages");
for (int pageNumber = fromPageNumber; pageNumber <= toPageNumber; pageNumber++)
}
catch...
finally
writer.close()