United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6549882 PNG reader should load RGB[A] images in display-optimal format
JDK-6549882 : PNG reader should load RGB[A] images in display-optimal format

Details
Type:
Bug
Submit Date:
2007-04-24
Status:
Resolved
Updated Date:
2011-01-19
Project Name:
JDK
Resolved Date:
2007-09-11
Component:
client-libs
OS:
generic
Sub-Component:
javax.imageio
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
1.4.0
Fixed Versions:

Related Reports
Backport:
Relates:

Sub Tasks

Description
PNG reader should load RGB[A] images in display-optimal format as do the JPEG and BMP readers.

                                    

Comments
WORK AROUND

Copy the loaded image into a non-TYPE_CUSTOM image thereby doubling the memory.
                                     
2007-04-24
SUGGESTED FIX

Two possible fixes:
1) Support two image types for RGB and RGBA, one corresponding to the existing type and one corresponding to TYPE_3BYTE_BGR and TYPE_4BYTE_ABGR[_PRE], respectively.
2) Replace the raw image type with the non-TYPE_CUSTOM variant.
                                     
2007-04-24
EVALUATION

The idea of this fix is to force png reader to create buffered image of
some standard type for pngs of color type RGB or RGBAlpha and bit depth
8.

I suggest to add appropriate standard image types to the list of image
types constructed by the reader. Namely:

 * for RGB color type we add TYPE_3BYTE_BGR, TYPE_INT_RGB and
    TYPE_INT_BGR.
 * for RGBAlpha color type we add TYPE_4BYTE_ABGR and TYPE_INT_RGB.

Also we need to override getRawImageType() method to keep custom
image type as a raw one. 

Note that destination types based on InteherInterleaveRaster (TYPE_INT_RGB, TYPE_INT_BGR, TYPE_INT_ARGB) may cause performance
degradation.  It is because ByteInterleavedRaster provides optimized
setRect() routine if argument is raster of same type. However IntegerInterleasvedRaster does not provide optimized setRect()
implementation and uses generic one inherited from WritableRaster class.

It seems to me that we get some improvements if we will use
getPixel()/setPixel() approach instead of setRect() for raster differ
form ByteInterleavedRaster.
                                     
2007-08-01



Hardware and Software, Engineered to Work Together