JDK-6297016 : Output BMP image is distorted when writing TYPE_3BYTE_BGR buff image with BI_BITFIELDS compression
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-14
  • Updated: 2011-01-19
  • Resolved: 2005-10-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
6 b56Fixed
Related Reports
Duplicate :  
Duplicate :  
Duplicate :  
I am writing a buffered image of type TYPE_3BYTE_BGR to a file using a BMP Writer. I am setting the compression type to BI_BITFIELDS in the image write param and using this param to write the image. The output image generated is completely distorted and unusable. None of the native image applications recognize this as a valid bmp image. 

The canEncodeImage() protected method in BMPWriter does not enforce any rectrictions in using this compression type with the given image, neither it throws an IOException saying this image type is not compatible with the specified compression.

This is reproducible on all platforms since Tiger-FCS.

I have attached a sample test which reproduces the bug. The 3rd image loaded onto a frame would be corrupted.
###@###.### 2005-07-14 17:35:09 GMT

EVALUATION This problem was caused by the fact that we wrote bitfileds masks to the bmp but do not change image data layout according to BMP format requirements. To fix this problem we should forec of using the writePixels() method in order to copy image data correctly.