JDK-6299168 : Setting subsampling alters the Image colors for INT_BGR when encoded with BMP writer
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-20
  • Updated: 2011-01-19
  • Resolved: 2006-04-03
Related Reports
Duplicate :  
Description
I am encoding a TYPE_INT_BGR image using BMP Writer with all the compression types supported. I have set the SourceSubsampling value to 3,3,0,0. When encoding with BI_RGB or BI_BITFIELDS compression types, some of the colors in the image are altered completely. This is incorrect. Setting subsampling should never alter the colors in the image.

This is reproducible only for BMP, only with the above compression types on all platforms. This is reproducible since Tiger.

I have attached a sample test and the image. I have also attached the screenshot of the output.
###@###.### 2005-07-20 07:19:35 GMT

Comments
EVALUATION The root of this problem is that writePixels() procedure does not take into account the difference of data layout for BI_RGB and BI_BITFIELDS compression and always uses RGB byte order that is appropriate for BI_BITFIELDS compression type. This problem was fixed by combination of two fixes in the BMP writer: - fix for the 5076878 shifts the problem with writing subsampled images from case of BI_RGB compression to case BI_BITFIELDS compression. - fix for the 6399660 updates writePixels() procedure to use data layout according to compression type in use. As soon as this problem was fixed as part of the 6399660, this bug should be closed as duplicate of 6399660. Please note that regression test for 6399660 covers problem described in this bug.
03-04-2006

EVALUATION This problem is caused by the extra band ordering operations in the writePixels() procedure. Please note that image data is ordered to BGR format before the writrePixels() invocation. The writePixels() procedure should assume that image is laready in the BGR order and do not perform any extra ordering operations.
02-10-2005