Bug 53408 - [PATCH] two new image loaders for PNG
Summary: [PATCH] two new image loaders for PNG
Status: CLOSED FIXED
Alias: None
Product: XMLGraphicsCommons - Now in Jira
Classification: Unclassified
Component: image codecs (show other bugs)
Version: Trunk
Hardware: All All
: P2 enhancement (vote)
Target Milestone: --
Assignee: XML Graphics Project Mailing List
URL:
Keywords:
Depends on:
Blocks: 40676
  Show dependency tree
 
Reported: 2012-06-13 12:57 UTC by Luis Bernardo
Modified: 2012-10-20 22:07 UTC (History)
0 users



Attachments
the patch (67.07 KB, patch)
2012-06-13 12:57 UTC, Luis Bernardo
Details | Diff
test images (8.96 KB, application/x-gzip)
2012-06-13 12:59 UTC, Luis Bernardo
Details
patch to replace previous one (66.83 KB, patch)
2012-06-13 14:51 UTC, Luis Bernardo
Details | Diff
support for sRGB and iCCP chunks (10.03 KB, patch)
2012-07-28 23:38 UTC, Luis Bernardo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luis Bernardo 2012-06-13 12:57:50 UTC
Created attachment 28927 [details]
the patch

This patch includes two new PNG image loaders, one that uses the internal XGC PNG codec, and is very much equivalent to to the ImageIO image loader, and another that does not do the decoding of the PNG IDAT chunk and instead accepts the "raw" chunk. The image loaders are named, respectively, ImageLoaderPNG, and ImageLoaderRawPNG. For now these image loaders have a default penalty of 1000 so that the default image loader is still ImageLoaderImageIO.

The ImageLoaderRawPNG has still some limitations on the type of PNG images that can handle. It only handles images with 8 bits per channel and without interlacing. Nevertheless, this image loader is particularly useful for large images encoded with the Paeth filter since it does not do the decoding (inverting the Paeth filter is very expensive). So besides being faster it also produces smaller output files.
Comment 1 Luis Bernardo 2012-06-13 12:59:55 UTC
Created attachment 28928 [details]
test images

attached are some test images to place in test/images. they are needed to run the unit tests. these images were obtained from here: http://www.schaik.com/pngsuite/
Comment 2 Luis Bernardo 2012-06-13 13:28:40 UTC
Note: for the record, this code, and the associated image handler for PDF in FOP, was initially prototyped by Matthias Reischenbacher and I built upon it. Thanks Matthias.
Comment 3 Glenn Adams 2012-06-13 13:30:29 UTC
(In reply to comment #0)
> Created attachment 28927 [details]
> the patch
> 
> This patch includes two new PNG image loaders, one that uses the internal
> XGC PNG codec, and is very much equivalent to to the ImageIO image loader,
> and another that does not do the decoding of the PNG IDAT chunk and instead
> accepts the "raw" chunk. The image loaders are named, respectively,
> ImageLoaderPNG, and ImageLoaderRawPNG. For now these image loaders have a
> default penalty of 1000 so that the default image loader is still
> ImageLoaderImageIO.
> 
> The ImageLoaderRawPNG has still some limitations on the type of PNG images
> that can handle. It only handles images with 8 bits per channel and without
> interlacing. Nevertheless, this image loader is particularly useful for
> large images encoded with the Paeth filter since it does not do the decoding
> (inverting the Paeth filter is very expensive). So besides being faster it
> also produces smaller output files.

This introduces two deprecated use warnings when compiling. Could you fix?

compile-java:
    [mkdir] Created dir: /users/glenn/Work/xgc/build/classes
    [javac] Compiling 290 source files to /users/glenn/Work/xgc/build/classes
    [javac] /users/glenn/Work/xgc/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java:279: warning: [deprecation] renderBitmapImage(java.awt.image.RenderedImage,float,float,float,float,org.apac\
he.xmlgraphics.ps.PSGenerator) in org.apache.xmlgraphics.ps.PSImageUtils has been deprecated
    [javac]             PSImageUtils.renderBitmapImage(buf,
    [javac]                         ^
    [javac] /users/glenn/Work/xgc/src/java/org/apache/xmlgraphics/java2d/ps/PSGraphics2D.java:650: warning: [deprecation] renderBitmapImage(java.awt.image.RenderedImage,float,float,float,float,org.apac\
he.xmlgraphics.ps.PSGenerator) in org.apache.xmlgraphics.ps.PSImageUtils has been deprecated
    [javac]             PSImageUtils.renderBitmapImage(img,
    [javac]                         ^
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 2 warnings
Comment 4 Glenn Adams 2012-06-13 13:34:43 UTC
(In reply to comment #2)
> Note: for the record, this code, and the associated image handler for PDF in
> FOP, was initially prototyped by Matthias Reischenbacher and I built upon
> it. Thanks Matthias.

Given the substance of the patch, and assuming Matthias' contribution was substantial, could you ask Matthias to submit an ICLA [1] to cover his portion of the contribution?

[1] http://www.apache.org/licenses/#clas
Comment 5 Luis Bernardo 2012-06-13 14:50:07 UTC
(In reply to comment #3)
> 
> This introduces two deprecated use warnings when compiling. Could you fix?
> 

Indeed! I had added the @deprecated myself since it seemed a good idea not to expose that method but since I cannot make a very strong case and there are side effects that I had missed I will remove it.
Comment 6 Luis Bernardo 2012-06-13 14:51:27 UTC
Created attachment 28931 [details]
patch to replace previous one

the @deprecated keyword was removed
Comment 7 Glenn Adams 2012-06-13 15:04:17 UTC
(In reply to comment #6)
> Created attachment 28931 [details]
> patch to replace previous one
> 
> the @deprecated keyword was removed

thanks; as soon as Matthias' ICLA is registered at [1] i will apply this and the related fop patches

[1] http://people.apache.org/committer-index.html#unlistedclas
Comment 8 Matthias Reischenbacher 2012-06-14 22:06:13 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > Created attachment 28931 [details]
> > patch to replace previous one
> > 
> > the @deprecated keyword was removed
> 
> thanks; as soon as Matthias' ICLA is registered at [1] i will apply this and
> the related fop patches
> 
> [1] http://people.apache.org/committer-index.html#unlistedclas

I've just sent my ICLA to secretary.

Thanks Luis for doing all the hard work and finishing this feature. It finally fixes a long standing problem. Thanks!
Comment 9 Glenn Adams 2012-06-15 02:31:06 UTC
patch applied at http://svn.apache.org/viewvc?rev=1350450&view=rev

thanks Luis & Matthias! please review and close if satisfied
Comment 10 Luis Bernardo 2012-07-28 23:38:54 UTC
Created attachment 29131 [details]
support for sRGB and iCCP chunks

this new patch improves the previous one by adding support for the sRGB and iCCP PNG chunks to the ImageLoaderRawPNG.
Comment 11 Luis Bernardo 2012-10-20 22:07:41 UTC
applied: http://svn.apache.org/viewvc?view=revision&revision=1400525