aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/image/analyser/JPEGReader.java
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2002-02-21 09:54:28 +0000
committerKeiron Liddle <keiron@apache.org>2002-02-21 09:54:28 +0000
commitfc9ae36c80dfaacf8ece2e9ddfc7514562dbf5cd (patch)
treeda590447386935437ec4dffcca99d849f9e80ee8 /src/org/apache/fop/image/analyser/JPEGReader.java
parent4e2d8dcbda10de725a8d024cf61574f87b66131d (diff)
downloadxmlgraphics-fop-fc9ae36c80dfaacf8ece2e9ddfc7514562dbf5cd.tar.gz
xmlgraphics-fop-fc9ae36c80dfaacf8ece2e9ddfc7514562dbf5cd.zip
some preliminary changes to image handling
Images are put into a cache, different cahces are possible if information is required it needs to be explicitly loaded git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194663 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/image/analyser/JPEGReader.java')
-rw-r--r--src/org/apache/fop/image/analyser/JPEGReader.java69
1 files changed, 36 insertions, 33 deletions
diff --git a/src/org/apache/fop/image/analyser/JPEGReader.java b/src/org/apache/fop/image/analyser/JPEGReader.java
index 0e1412a8b..16964e4fe 100644
--- a/src/org/apache/fop/image/analyser/JPEGReader.java
+++ b/src/org/apache/fop/image/analyser/JPEGReader.java
@@ -11,6 +11,8 @@ package org.apache.fop.image.analyser;
import java.io.BufferedInputStream;
import java.io.IOException;
+import org.apache.fop.fo.FOUserAgent;
+
/**
* ImageReader object for JPEG image type.
* @author Pankaj Narula
@@ -25,26 +27,26 @@ public class JPEGReader extends AbstractImageReader {
* inside the APPn marker. And we don't want to confuse those dimensions with
* the image dimensions.
*/
- static protected final int MARK = 0xff; // Beginneing of a Marker
- static protected final int NULL = 0x00; // Special case for 0xff00
- static protected final int SOF1 = 0xc0; // Baseline DCT
- static protected final int SOF2 = 0xc1; // Extended Sequential DCT
- static protected final int SOF3 = 0xc2; // Progrssive DCT only PDF 1.3
- static protected final int SOFA = 0xca; // Progressice DCT only PDF 1.3
- static protected final int APP0 = 0xe0; // Application marker, JFIF
- static protected final int APPF = 0xef; // Application marker
- static protected final int SOS = 0xda; // Start of Scan
- static protected final int SOI = 0xd8; // start of Image
+ static protected final int MARK = 0xff; // Beginneing of a Marker
+ static protected final int NULL = 0x00; // Special case for 0xff00
+ static protected final int SOF1 = 0xc0; // Baseline DCT
+ static protected final int SOF2 = 0xc1; // Extended Sequential DCT
+ static protected final int SOF3 = 0xc2; // Progrssive DCT only PDF 1.3
+ static protected final int SOFA = 0xca; // Progressice DCT only PDF 1.3
+ static protected final int APP0 = 0xe0; // Application marker, JFIF
+ static protected final int APPF = 0xef; // Application marker
+ static protected final int SOS = 0xda; // Start of Scan
+ static protected final int SOI = 0xd8; // start of Image
static protected final int JPG_SIG_LENGTH = 2;
protected byte[] header;
- public boolean verifySignature(String uri, BufferedInputStream fis)
- throws IOException {
+ public boolean verifySignature(String uri, BufferedInputStream fis,
+ FOUserAgent ua) throws IOException {
this.imageStream = fis;
this.setDefaultHeader();
- boolean supported = ((header[0] == (byte)0xff)
- && (header[1] == (byte)0xd8));
+ boolean supported = ((header[0] == (byte) 0xff) &&
+ (header[1] == (byte) 0xd8));
if (supported) {
setDimension();
return true;
@@ -81,25 +83,26 @@ public class JPEGReader extends AbstractImageReader {
}
do {
marker = imageStream.read();
- } while (marker == MARK);
+ } while (marker == MARK)
+ ;
switch (marker) {
- case SOI:
- break;
- case NULL:
- break;
- case SOF1:
- case SOF2:
- case SOF3: // SOF3 and SOFA are only supported by PDF 1.3
- case SOFA:
- this.skip(3);
- this.height = this.read2bytes();
- this.width = this.read2bytes();
- break outer;
- default:
- length = this.read2bytes();
- skipped = this.skip(length - 2);
- if (skipped != length - 2)
- throw new IOException("Skipping Error");
+ case SOI:
+ break;
+ case NULL:
+ break;
+ case SOF1:
+ case SOF2:
+ case SOF3: // SOF3 and SOFA are only supported by PDF 1.3
+ case SOFA:
+ this.skip(3);
+ this.height = this.read2bytes();
+ this.width = this.read2bytes();
+ break outer;
+ default:
+ length = this.read2bytes();
+ skipped = this.skip(length - 2);
+ if (skipped != length - 2)
+ throw new IOException("Skipping Error");
}
}
} catch (IOException ioe) {
@@ -122,7 +125,7 @@ public class JPEGReader extends AbstractImageReader {
imageStream.read();
discarded++;
}
- return discarded; // scope for exception
+ return discarded; // scope for exception
}
}