See the attached program and bmp file. When the com.sun.javafx.iio.ImageStorage.loadAll() method is given a stream that, when requested 384 bytes, returns fewer than 384 bytes, the image gets loaded incorrectly. I think the problem is in the following code in javafx-iio/src/com/sun/javafx/iio/bmp/BMPImageLoaderFactory.java:
186 int nRead = data.in.read(image, line * bmpStride, bmpStride);
187 GBRtoRGB(image, line * bmpStride, nRead);
188 if (nRead < bmpStride) {
189 break;
190 }
This code seems to assume that InputStream.read(byte[] b, int off, int len) returning fewer than 'len' bytes indicates the end of stream, which is not true per the InputStream.read(byte[] b, int off, int len) spec.
The test program is supposed to be run with the j2d pipeline.
186 int nRead = data.in.read(image, line * bmpStride, bmpStride);
187 GBRtoRGB(image, line * bmpStride, nRead);
188 if (nRead < bmpStride) {
189 break;
190 }
This code seems to assume that InputStream.read(byte[] b, int off, int len) returning fewer than 'len' bytes indicates the end of stream, which is not true per the InputStream.read(byte[] b, int off, int len) spec.
The test program is supposed to be run with the j2d pipeline.
- relates to
-
JDK-8096936 Decoding BMP file throws an exception
- Resolved
-
JDK-8114224 BMP images display is not supported in WebNode
- Closed