Skip to content

Commit

Permalink
Fixes for V4 Bitmap reading.
Browse files Browse the repository at this point in the history
  • Loading branch information
kntroh committed Apr 17, 2015
1 parent 0d2f2fa commit af053af
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/org/eclipse/swt/internal/image/LEDataInputStream.d
Expand Up @@ -103,6 +103,16 @@ final class LEDataInputStream : InputStream{
return read;
}

public override long skip(long n) {
if (buf.length < position + n) {
n = buf.length - position;
}
pos += n;
position += n;
host.skip(n);
return n;
}

/**
* Reads at most <code>length</code> bytes from this LEDataInputStream and
* stores them in byte array <code>buffer</code> starting at <code>offset</code>.
Expand Down
9 changes: 9 additions & 0 deletions src/org/eclipse/swt/internal/image/WinBMPFileFormat.d
Expand Up @@ -440,11 +440,20 @@ override ImageData[] loadFromByteStream() {
} catch (Exception e) {
SWT.error(SWT.ERROR_IO, e);
}
int headerSize = (infoHeader[0] & 0xFF) | ((infoHeader[1] & 0xFF) << 8) | ((infoHeader[2] & 0xFF) << 16) | ((infoHeader[3] & 0xFF) << 24);
int width = (infoHeader[4] & 0xFF) | ((infoHeader[5] & 0xFF) << 8) | ((infoHeader[6] & 0xFF) << 16) | ((infoHeader[7] & 0xFF) << 24);
int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24);
if (height < 0) height = -height;
int bitCount = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
this.compression = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
if (inputStream.getPosition() < (BMPFileHeaderSize + headerSize)) {
// Seek to the specified offset
try {
inputStream.skip((BMPFileHeaderSize + headerSize) - inputStream.getPosition());
} catch (IOException e) {
SWT.error(SWT.ERROR_IO, e);
}
}
PaletteData palette = loadPalette(infoHeader);
if (inputStream.getPosition() < fileHeader[4]) {
// Seek to the specified offset
Expand Down

0 comments on commit af053af

Please sign in to comment.