DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42998>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42998

           Summary: NullPointerException in TiffImageWriter if JPEG is
                    chosen for compression
           Product: XMLGraphicsCommons
           Version: 1.2
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: major
          Priority: P2
         Component: ImageWriter
        AssignedTo: [email protected]
        ReportedBy: [EMAIL PROTECTED]


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++)
                                {
                                        BufferedImage image;
                                        
                                        <snip>
                                        // do stuff to create image
                                        </snip>
                                        log.info("write image");
                                        writer.writeImage(image, iwp);
                                }
                        }
                catch...
                finally
                writer.close()

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to