8278805: Enhance BMP image loading

Reviewed-by: prr, azvegint, rhalade, mschoene
This commit is contained in:
Jayathirth D V 2022-01-14 17:53:40 +00:00 committed by Henry Jen
parent 616ea1692e
commit 74318dfb9d

View File

@ -67,6 +67,7 @@ import javax.imageio.stream.ImageInputStream;
import com.sun.imageio.plugins.common.I18N;
import com.sun.imageio.plugins.common.ImageUtil;
import com.sun.imageio.plugins.common.ReaderUtil;
/** This class is the Java Image IO plugin reader for BMP images.
* It may subsample the image, clip the image, select sub-bands,
@ -1542,9 +1543,8 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
}
// Read till we have the whole image
byte[] values = new byte[imSize];
int bytesRead = 0;
iis.readFully(values, 0, imSize);
byte[] values = ReaderUtil.
staggeredReadByteStream(iis, imSize);
// Since data is compressed, decompress it
decodeRLE8(imSize, padding, values, bdata);
@ -1726,8 +1726,8 @@ public class BMPImageReader extends ImageReader implements BMPConstants {
}
// Read till we have the whole image
byte[] values = new byte[imSize];
iis.readFully(values, 0, imSize);
byte[] values = ReaderUtil.
staggeredReadByteStream(iis, imSize);
// Decompress the RLE4 compressed data.
decodeRLE4(imSize, padding, values, bdata);