JDK-6332480 : BMP Reader fails to read the TYPE_BYTE_GRAY image encoded by BMP Writer with BI_RLE8 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-10-04
  • Updated: 2011-01-19
  • Resolved: 2005-12-05
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.
JDK 6
6 b63Fixed
Description
I am encoding a TYPE_BYTE_GRAY image using BMP Writer with an ImageWriteParam set with the compression type - BI_RLE8. When I read back the output image using corresponding BMP Reader, the image is not completely read and only 3/4th of the image gets loaded. Rest of the image looks black. 

This is reproducible on all platforms since Tiger-FCS. (On tiger/mustang builds other than b56 PIT build, you would see an extra NPE with BI_BITFIELDS that is due to the bug - 6294960). But actually the image is created properly and all the native image viewers are able to load the image properly.

I have attached a sample test and an image. 
Run the attached test as follows:
'java BMPWriterByteGrayTest bmp'.
You would see many images being loaded on to a frame, typically one for each compression type. If the third image is not loaded completely, the bug is reproduced.

Comments
EVALUATION The reason of problem is that RLE decoding procedures (both RLE4 and RLE8) mistakenly use the width of destination region instead of the height to calculate the range of image lines for copying. The fix is to use the height of destination region for this.
2005-10-10