< prev index next >
src/java.desktop/share/classes/com/sun/imageio/plugins/bmp/BMPImageReader.java
Print this page
*** 120,130 ****
private long bitmapFileSize;
private long bitmapOffset;
private long bitmapStart;
private long compression;
private long imageSize;
! private byte palette[];
private int imageType;
private int numBands;
private boolean isBottomUp;
private int bitsPerPixel;
private int redMask, greenMask, blueMask, alphaMask;
--- 120,130 ----
private long bitmapFileSize;
private long bitmapOffset;
private long bitmapStart;
private long compression;
private long imageSize;
! private byte[] palette;
private int imageType;
private int numBands;
private boolean isBottomUp;
private int bitsPerPixel;
private int redMask, greenMask, blueMask, alphaMask;
*** 653,663 ****
width, height,
bitsPerPixel);
}
// Create IndexColorModel from the palette.
! byte r[], g[], b[];
if (imageType == VERSION_2_1_BIT ||
imageType == VERSION_2_4_BIT ||
imageType == VERSION_2_8_BIT) {
--- 653,663 ----
width, height,
bitsPerPixel);
}
// Create IndexColorModel from the palette.
! byte[] r, g, b;
if (imageType == VERSION_2_1_BIT ||
imageType == VERSION_2_4_BIT ||
imageType == VERSION_2_8_BIT) {
*** 883,895 ****
colorModel = bi.getColorModel();
noTransform &= destinationRegion.equals(raster.getBounds());
}
! byte bdata[] = null; // buffer for byte data
! short sdata[] = null; // buffer for short data
! int idata[] = null; // buffer for int data
// the sampleModel can be null in case of embedded image
if (sampleModel != null) {
if (sampleModel.getDataType() == DataBuffer.TYPE_BYTE)
bdata = ((DataBufferByte)raster.getDataBuffer()).getData();
--- 883,895 ----
colorModel = bi.getColorModel();
noTransform &= destinationRegion.equals(raster.getBounds());
}
! byte[] bdata = null; // buffer for byte data
! short[] sdata = null; // buffer for short data
! int[] idata = null; // buffer for int data
// the sampleModel can be null in case of embedded image
if (sampleModel != null) {
if (sampleModel.getDataType() == DataBuffer.TYPE_BYTE)
bdata = ((DataBufferByte)raster.getDataBuffer()).getData();
*** 1366,1376 ****
}
}
}
}
! private void read16Bit(short sdata[]) throws IOException {
// Padding bytes at the end of each scanline
// width * bitsPerPixel should be divisible by 32
int padding = width * 2 % 4;
if ( padding != 0)
--- 1366,1376 ----
}
}
}
}
! private void read16Bit(short[] sdata) throws IOException {
// Padding bytes at the end of each scanline
// width * bitsPerPixel should be divisible by 32
int padding = width * 2 % 4;
if ( padding != 0)
*** 1432,1442 ****
}
}
}
}
! private void read32Bit(int idata[]) throws IOException {
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
iis.readFully(idata, j, width);
--- 1432,1442 ----
}
}
}
}
! private void read32Bit(int[] idata) throws IOException {
if (noTransform) {
int j = isBottomUp ? (height -1) * width : 0;
for (int i=0; i<height; i++) {
iis.readFully(idata, j, width);
*** 1488,1498 ****
}
}
}
}
! private void readRLE8(byte bdata[]) throws IOException {
// If imageSize field is not provided, calculate it.
int imSize = (int)imageSize;
if (imSize == 0) {
imSize = (int)(bitmapFileSize - bitmapOffset);
}
--- 1488,1498 ----
}
}
}
}
! private void readRLE8(byte[] bdata) throws IOException {
// If imageSize field is not provided, calculate it.
int imSize = (int)imageSize;
if (imSize == 0) {
imSize = (int)(bitmapFileSize - bitmapOffset);
}
*** 1504,1514 ****
if (remainder != 0) {
padding = 4 - remainder;
}
// Read till we have the whole image
! byte values[] = new byte[imSize];
int bytesRead = 0;
iis.readFully(values, 0, imSize);
// Since data is compressed, decompress it
decodeRLE8(imSize, padding, values, bdata);
--- 1504,1514 ----
if (remainder != 0) {
padding = 4 - remainder;
}
// Read till we have the whole image
! byte[] values = new byte[imSize];
int bytesRead = 0;
iis.readFully(values, 0, imSize);
// Since data is compressed, decompress it
decodeRLE8(imSize, padding, values, bdata);
*** 1560,1570 ****
private void decodeRLE8(int imSize,
int padding,
byte[] values,
byte[] bdata) throws IOException {
! byte val[] = new byte[width];
int count = 0, l = 0;
int value;
boolean flag = false;
int lineNo = isBottomUp ? height - 1 : 0;
int finished = 0;
--- 1560,1570 ----
private void decodeRLE8(int imSize,
int padding,
byte[] values,
byte[] bdata) throws IOException {
! byte[] val = new byte[width];
int count = 0, l = 0;
int value;
boolean flag = false;
int lineNo = isBottomUp ? height - 1 : 0;
int finished = 0;
*** 1862,1872 ****
} else {
// Encoded mode
// Ensure to check if the source index-count, does not
// exceed the source image size
if (count < imSize) {
! int alternate[] = { (values[count] & 0xf0) >> 4,
values[count] & 0x0f };
for (int i=0; (i < value) && (l < width); i++) {
val[l++] = (byte)alternate[i & 1];
}
}
--- 1862,1872 ----
} else {
// Encoded mode
// Ensure to check if the source index-count, does not
// exceed the source image size
if (count < imSize) {
! int[] alternate = { (values[count] & 0xf0) >> 4,
values[count] & 0x0f };
for (int i=0; (i < value) && (l < width); i++) {
val[l++] = (byte)alternate[i & 1];
}
}
< prev index next >