diff options
author | Carolyn MacLeod <carolyn> | 2006-09-20 21:16:55 +0000 |
---|---|---|
committer | Carolyn MacLeod <carolyn> | 2006-09-20 21:16:55 +0000 |
commit | 99e437fa580702168e537f4a5d7239ece222d7cb (patch) | |
tree | 266d8cc8f083eaa028a70b471176a301073e1740 | |
parent | a40e558ac59f0b5632bc9fe258fa90c255a9aa17 (diff) | |
download | eclipse.platform.swt-99e437fa580702168e537f4a5d7239ece222d7cb.tar.gz eclipse.platform.swt-99e437fa580702168e537f4a5d7239ece222d7cb.tar.xz eclipse.platform.swt-99e437fa580702168e537f4a5d7239ece222d7cb.zip |
157689 - Problem loading BMP with negative height (bottom-up)
2 files changed, 3 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java index ed750851a5..3c7f49174d 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java @@ -343,6 +343,7 @@ byte[] loadData(byte[] infoHeader) { } byte[] loadData(byte[] infoHeader, int stride) { int height = (infoHeader[8] & 0xFF) | ((infoHeader[9] & 0xFF) << 8) | ((infoHeader[10] & 0xFF) << 16) | ((infoHeader[11] & 0xFF) << 24); + if (height < 0) height = -height; int dataSize = height * stride; byte[] data = new byte[dataSize]; int cmp = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24); @@ -391,6 +392,7 @@ ImageData[] loadFromByteStream() { } 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); PaletteData palette = loadPalette(infoHeader); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java index ae06872947..74c680f4f1 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java @@ -131,6 +131,7 @@ ImageData loadIcon(int[] iconHeader) { byte[] shapeData = bmpFormat.loadData(infoHeader); 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 depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8); infoHeader[14] = 1; infoHeader[15] = 0; |