summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarolyn MacLeod <carolyn>2008-01-31 18:17:22 +0000
committerCarolyn MacLeod <carolyn>2008-01-31 18:17:22 +0000
commitb9424a5bc4808483b5f0287d91bb9a21a656b499 (patch)
tree4396f74a8f4d33e8279f6838af9a3bb9444dcba4
parent7f3d866c4140cd4f8ccd06beca69339b6dfdde1e (diff)
downloadeclipse.platform.swt-b9424a5bc4808483b5f0287d91bb9a21a656b499.tar.gz
eclipse.platform.swt-b9424a5bc4808483b5f0287d91bb9a21a656b499.tar.xz
eclipse.platform.swt-b9424a5bc4808483b5f0287d91bb9a21a656b499.zip
217242 - PNG cannot be loaded anymore, worked with releases before
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
index e03f0f25d6..0e45eb9cd0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -426,7 +426,14 @@ ImageData(
int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1))
/ scanlinePad * scanlinePad;
- if (data != null && data.length < bytesPerLine * height) {
+ /*
+ * When the image is being loaded from a PNG, we need to use the theoretical minimum
+ * number of bytes per line to check whether there is enough data, because the actual
+ * number of bytes per line is calculated based on the given depth, which may be larger
+ * than the actual depth of the PNG.
+ */
+ int minBytesPerLine = type == SWT.IMAGE_PNG ? ((((width + 7) / 8) + 3) / 4) * 4 : bytesPerLine;
+ if (data != null && data.length < minBytesPerLine * height) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
setAllFields(