Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Heidrich2006-07-24 20:16:40 +0000
committerFelipe Heidrich2006-07-24 20:16:40 +0000
commit2932cda2665961803ee1f9ce4c664b53826c4f18 (patch)
tree74015a0c94c94315cd30e62ce69f91ce7489797d /bundles
parenta84996bbb9b56234593b8b2406c1c8b5d9dd5115 (diff)
downloadeclipse.platform.swt-2932cda2665961803ee1f9ce4c664b53826c4f18.tar.gz
eclipse.platform.swt-2932cda2665961803ee1f9ce4c664b53826c4f18.tar.xz
eclipse.platform.swt-2932cda2665961803ee1f9ce4c664b53826c4f18.zip
pow2(depth) = 1 << depth and PNG spec says chunk type uses a-zA-Z values only
Diffstat (limited to 'bundles')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java3
3 files changed, 10 insertions, 8 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
index 1847884c6a..ee7e753005 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
@@ -12,7 +12,6 @@ package org.eclipse.swt.internal.image;
import org.eclipse.swt.*;
-import org.eclipse.swt.internal.Compatibility;
import java.io.*;
class PngChunk extends Object {
@@ -272,7 +271,8 @@ boolean typeMatchesArray(byte[] array) {
}
boolean isCritical() {
- return Character.isUpperCase((char) getTypeBytes()[0]);
+ char c = (char) getTypeBytes()[0];
+ return 'A' <= c && c <= 'Z';
}
int getChunkType() {
@@ -331,11 +331,15 @@ void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
byte[] type = getTypeBytes();
// The third character MUST be upper case.
- if (!Character.isUpperCase((char) type[2])) SWT.error(SWT.ERROR_INVALID_IMAGE);
+ char c = (char) type[2];
+ if (!('A' <= c && c <= 'Z')) SWT.error(SWT.ERROR_INVALID_IMAGE);
// All characters must be letters.
for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
- if (!Compatibility.isLetter((char) type[i])) SWT.error(SWT.ERROR_INVALID_IMAGE);
+ c = (char) type[i];
+ if (!(('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'))) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
}
// The stored CRC must match the data's computed CRC.
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
index 987f559cc2..a92c9a9358 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
@@ -13,7 +13,6 @@ package org.eclipse.swt.internal.image;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
class PngIhdrChunk extends PngChunk {
static final int IHDR_DATA_LENGTH = 13;
@@ -379,7 +378,7 @@ boolean usesDirectColor() {
PaletteData createGrayscalePalette() {
int depth = Math.min(bitDepth, 8);
- int max = Compatibility.pow2(depth) - 1;
+ int max = (1 << depth) - 1;
int delta = 255 / max;
int gray = 0;
RGB[] rgbs = new RGB[max + 1];
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
index a216966533..164530aead 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
@@ -13,7 +13,6 @@ package org.eclipse.swt.internal.image;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
-import org.eclipse.swt.internal.Compatibility;
class PngPlteChunk extends PngChunk {
@@ -106,7 +105,7 @@ void validate(PngFileReadState readState, PngIhdrChunk headerChunk) {
// Palettes cannot have more entries than 2^bitDepth
// where bitDepth is the bit depth of the image given
// in the IHDR chunk.
- if (Compatibility.pow2(headerChunk.getBitDepth()) < paletteSize) {
+ if (1 << headerChunk.getBitDepth() < paletteSize) {
SWT.error(SWT.ERROR_INVALID_IMAGE);
}

Back to the top