aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/image
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2006-04-04 15:15:23 +0000
committerJeremias Maerki <jeremias@apache.org>2006-04-04 15:15:23 +0000
commitdece1d7361bfe21604222d1dbfdc1b599084a363 (patch)
tree15e90914861c79b74e32f8ae82176e29d9059c90 /src/java/org/apache/fop/image
parent46f47c3095c086d88ff7d652aee40303a9ed9601 (diff)
downloadxmlgraphics-fop-dece1d7361bfe21604222d1dbfdc1b599084a363.tar.gz
xmlgraphics-fop-dece1d7361bfe21604222d1dbfdc1b599084a363.zip
Adding dependency on XML Graphics Commons.
Switching to code in XML Graphics Commons for: - PSGraphics2D - Service discovery - Codecs Removed local classes that have been ported to Commons. xmlgraphics-commons-snapshot.jar is a Trunk snapshot built with JDK 1.4.2 from today. It should work under JDK 1.3.1. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@391332 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/image')
-rw-r--r--src/java/org/apache/fop/image/PNGImage.java19
-rw-r--r--src/java/org/apache/fop/image/TIFFImage.java23
-rw-r--r--src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java (renamed from src/java/org/apache/fop/image/BatikImage.java)85
3 files changed, 68 insertions, 59 deletions
diff --git a/src/java/org/apache/fop/image/PNGImage.java b/src/java/org/apache/fop/image/PNGImage.java
index 6cf50d47c..43cfbe97f 100644
--- a/src/java/org/apache/fop/image/PNGImage.java
+++ b/src/java/org/apache/fop/image/PNGImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 The Apache Software Foundation
+ * Copyright 2004-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,17 +18,13 @@
package org.apache.fop.image;
-import java.awt.color.ColorSpace;
-import java.awt.color.ICC_Profile;
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
-import org.apache.batik.ext.awt.image.codec.PNGRed;
-import org.apache.batik.ext.awt.image.codec.PNGDecodeParam;
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.codec.png.PNGRed;
+import org.apache.xmlgraphics.image.codec.png.PNGDecodeParam;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
import org.apache.commons.io.IOUtils;
-import org.apache.fop.util.CMYKColorSpace;
/**
* FopImage object using PNG
@@ -36,7 +32,7 @@ import org.apache.fop.util.CMYKColorSpace;
* @see AbstractFopImage
* @see FopImage
*/
-public class PNGImage extends BatikImage {
+public class PNGImage extends XmlGraphicsCommonsImage {
/**
* Constructs a new PNGImage instance.
@@ -48,7 +44,8 @@ public class PNGImage extends BatikImage {
}
/**
- * @see org.apache.fop.image.BatikImage#decodeImage(org.apache.batik.ext.awt.image.codec.SeekableStream)
+ * @see org.apache.fop.image.XmlGraphicsCommonsImage#decodeImage(
+ * org.apache.xmlgraphics.image.codec.util.SeekableStream)
*/
protected CachableRed decodeImage(SeekableStream stream) throws IOException {
PNGDecodeParam param = new PNGDecodeParam();
diff --git a/src/java/org/apache/fop/image/TIFFImage.java b/src/java/org/apache/fop/image/TIFFImage.java
index 7aa327c99..23337d01e 100644
--- a/src/java/org/apache/fop/image/TIFFImage.java
+++ b/src/java/org/apache/fop/image/TIFFImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 The Apache Software Foundation
+ * Copyright 2004-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,17 +21,17 @@ package org.apache.fop.image;
import java.awt.color.ColorSpace;
import java.io.IOException;
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFDirectory;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFField;
-import org.apache.batik.ext.awt.image.codec.tiff.TIFFImageDecoder;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFDirectory;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFField;
+import org.apache.xmlgraphics.image.codec.tiff.TIFFImageDecoder;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
import org.apache.commons.io.IOUtils;
/**
* TIFF implementation using the Batik codecs.
*/
-public class TIFFImage extends BatikImage {
+public class TIFFImage extends XmlGraphicsCommonsImage {
private int compression = 0;
private int stripCount = 0;
@@ -62,10 +62,13 @@ public class TIFFImage extends BatikImage {
return stripCount;
}
- /** @see org.apache.fop.image.BatikImage */
+ /**
+ * @see org.apache.fop.image.XmlGraphicsCommonsImage#decodeImage(
+ * org.apache.xmlgraphics.image.codec.util.SeekableStream)
+ */
protected CachableRed decodeImage(SeekableStream stream) throws IOException {
- org.apache.batik.ext.awt.image.codec.tiff.TIFFImage img
- = new org.apache.batik.ext.awt.image.codec.tiff.TIFFImage
+ org.apache.xmlgraphics.image.codec.tiff.TIFFImage img
+ = new org.apache.xmlgraphics.image.codec.tiff.TIFFImage
(stream, null, 0);
TIFFDirectory dir = (TIFFDirectory)img.getProperty("tiff_directory");
TIFFField fld = dir.getField(TIFFImageDecoder.TIFF_RESOLUTION_UNIT);
diff --git a/src/java/org/apache/fop/image/BatikImage.java b/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java
index 1f6d7405b..ee079aad5 100644
--- a/src/java/org/apache/fop/image/BatikImage.java
+++ b/src/java/org/apache/fop/image/XmlGraphicsCommonsImage.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 The Apache Software Foundation
+ * Copyright 2004-2006 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,24 +22,25 @@ import java.awt.Color;
import java.awt.Transparency;
import java.awt.image.ColorModel;
import java.awt.image.IndexColorModel;
+import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.awt.image.BufferedImage;
import java.io.IOException;
-import org.apache.batik.ext.awt.image.codec.SeekableStream;
-import org.apache.batik.ext.awt.image.codec.MemoryCacheSeekableStream;
-import org.apache.batik.ext.awt.image.codec.FileCacheSeekableStream;
-import org.apache.batik.ext.awt.image.rendered.Any2sRGBRed;
-import org.apache.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.xmlgraphics.image.GraphicsUtil;
+import org.apache.xmlgraphics.image.codec.util.SeekableStream;
+import org.apache.xmlgraphics.image.codec.util.MemoryCacheSeekableStream;
+import org.apache.xmlgraphics.image.codec.util.FileCacheSeekableStream;
+import org.apache.xmlgraphics.image.rendered.CachableRed;
+
import org.apache.commons.io.IOUtils;
/**
- * FopImage object using TIFF
- * @author Eric SCHAEFFER
+ * Abstract FopImage implementation which uses the internal codecs from XML Graphics Commons.
* @see AbstractFopImage
* @see FopImage
*/
-public abstract class BatikImage extends AbstractFopImage {
+public abstract class XmlGraphicsCommonsImage extends AbstractFopImage {
private byte[] softMask = null;
@@ -57,7 +58,7 @@ public abstract class BatikImage extends AbstractFopImage {
* Constructs a new BatikImage instance.
* @param imgReader basic metadata for the image
*/
- public BatikImage(FopImage.ImageInfo imgReader) {
+ public XmlGraphicsCommonsImage(FopImage.ImageInfo imgReader) {
super(imgReader);
}
@@ -105,7 +106,7 @@ public abstract class BatikImage extends AbstractFopImage {
}
}
} else {
- cr = new Any2sRGBRed(cr);
+ cr = GraphicsUtil.convertTosRGB(cr);
}
// Get our current ColorModel
@@ -187,32 +188,7 @@ public abstract class BatikImage extends AbstractFopImage {
this.bitmaps = new byte[this.width * this.height * 3];
- WritableRaster wr = (WritableRaster)cr.getData();
- BufferedImage bi = new BufferedImage
- (cm, wr.createWritableTranslatedChild(0, 0),
- cm.isAlphaPremultiplied(), null);
- int [] tmpMap = new int[this.width];
- int idx = 0;
- int sfIdx = 0;
- for (int y = 0; y < this.height; y++) {
- tmpMap = bi.getRGB(0, y, this.width, 1, tmpMap, 0, this.width);
- if (softMask != null) {
- for (int x = 0; x < this.width; x++) {
- int pix = tmpMap[x];
- this.softMask[sfIdx++] = (byte)(pix >>> 24);
- this.bitmaps[idx++] = (byte)((pix >>> 16) & 0xFF);
- this.bitmaps[idx++] = (byte)((pix >>> 8) & 0xFF);
- this.bitmaps[idx++] = (byte)((pix) & 0xFF);
- }
- } else {
- for (int x = 0; x < this.width; x++) {
- int pix = tmpMap[x];
- this.bitmaps[idx++] = (byte)((pix >> 16) & 0xFF);
- this.bitmaps[idx++] = (byte)((pix >> 8) & 0xFF);
- this.bitmaps[idx++] = (byte)((pix) & 0xFF);
- }
- }
- }
+ constructBitmaps(cr, this.bitmaps, this.softMask);
} catch (Exception ex) {
log.error("Error while loading image (Batik): " + ex.getMessage(), ex);
} finally {
@@ -225,4 +201,37 @@ public abstract class BatikImage extends AbstractFopImage {
}
}
}
-};
+
+ private static void constructBitmaps(RenderedImage red, byte[] bitmaps, byte[] softMask) {
+ WritableRaster wr = (WritableRaster)red.getData();
+ ColorModel cm = red.getColorModel();
+ BufferedImage bi = new BufferedImage
+ (cm, wr.createWritableTranslatedChild(0, 0),
+ cm.isAlphaPremultiplied(), null);
+ int width = red.getWidth();
+ int height = red.getHeight();
+ int [] tmpMap = new int[width];
+ int idx = 0;
+ int sfIdx = 0;
+ for (int y = 0; y < height; y++) {
+ tmpMap = bi.getRGB(0, y, width, 1, tmpMap, 0, width);
+ if (softMask != null) {
+ for (int x = 0; x < width; x++) {
+ int pix = tmpMap[x];
+ softMask[sfIdx++] = (byte)(pix >>> 24);
+ bitmaps[idx++] = (byte)((pix >>> 16) & 0xFF);
+ bitmaps[idx++] = (byte)((pix >>> 8) & 0xFF);
+ bitmaps[idx++] = (byte)((pix) & 0xFF);
+ }
+ } else {
+ for (int x = 0; x < width; x++) {
+ int pix = tmpMap[x];
+ bitmaps[idx++] = (byte)((pix >> 16) & 0xFF);
+ bitmaps[idx++] = (byte)((pix >> 8) & 0xFF);
+ bitmaps[idx++] = (byte)((pix) & 0xFF);
+ }
+ }
+ }
+ }
+
+} \ No newline at end of file