Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
index 6a9413bdb9..2dd958778e 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
@@ -1,15 +1,15 @@
package org.eclipse.swt.internal.image;
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved
+ */
+
import java.io.*;
import java.util.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-/*
- * Licensed Materials - Property of IBM,
- * WebSphere Studio Workbench
- * (c) Copyright IBM Corp 2000
- */
public class PNGFileFormat extends FileFormat {
static final int SIGNATURE_LENGTH = 8;
PngDecodingDataStream decodingStream;
@@ -171,7 +171,13 @@ void setPixelData(byte[] data, ImageData imageData) {
int width = imageData.width;
int height = imageData.height;
int destBytesPerLine = imageData.bytesPerLine;
- int srcBytesPerLine = width * 2;
+ /*
+ * If the image uses 16-bit depth, it is converted
+ * to an 8-bit depth image.
+ */
+ int srcBytesPerLine = getAlignedBytesPerRow();
+ if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
byte[] rgbData = new byte[destBytesPerLine * height];
byte[] alphaData = new byte[width * height];
for (int y = 0; y < height; y++) {
@@ -200,6 +206,12 @@ void setPixelData(byte[] data, ImageData imageData) {
int height = imageData.height;
int destBytesPerLine = imageData.bytesPerLine;
int srcBytesPerLine = getAlignedBytesPerRow();
+ /*
+ * If the image uses 16-bit depth, it is converted
+ * to an 8-bit depth image.
+ */
+ if (headerChunk.getBitDepth() > 8) srcBytesPerLine /= 2;
+
byte[] rgbData = new byte[destBytesPerLine * height];
byte[] alphaData = new byte[width * height];
for (int y = 0; y < height; y++) {
@@ -522,4 +534,4 @@ void filterRow(byte[] row, byte[] previousRow, int filterType) {
}
}
-} \ No newline at end of file
+}

Back to the top