]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
for generic FOP image processing (i.e. not related to rendering), use java.awt.Color...
authorWilliam Victor Mote <vmote@apache.org>
Sat, 30 Aug 2003 17:59:54 +0000 (17:59 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Sat, 30 Aug 2003 17:59:54 +0000 (17:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196874 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/image/AbstractFopImage.java
src/java/org/apache/fop/image/FopImage.java
src/java/org/apache/fop/image/GifImage.java
src/java/org/apache/fop/image/JAIImage.java
src/java/org/apache/fop/image/JimiImage.java
src/java/org/apache/fop/render/pdf/FopPDFImage.java

index d5186d03cd61dcc4a765e6b654904c3c6874fbbb..8824c8cd0a1020cb994fe0bc426baeb527f5c21b 100644 (file)
@@ -3,34 +3,34 @@
  * ============================================================================
  *                    The Apache Software License, Version 1.1
  * ============================================================================
- * 
+ *
  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without modifica-
  * tion, are permitted provided that the following conditions are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice,
  *    this list of conditions and the following disclaimer.
- * 
+ *
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution, if any, must
  *    include the following acknowledgment: "This product includes software
  *    developed by the Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself, if
  *    and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  *    endorse or promote products derived from this software without prior
  *    written permission. For written permission, please contact
  *    apache@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache", nor may
  *    "Apache" appear in their name, without prior written permission of the
  *    Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * ============================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many individuals
  * on behalf of the Apache Software Foundation and was originally created by
  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  * Software Foundation, please see <http://www.apache.org/>.
- */ 
+ */
 package org.apache.fop.image;
 
 // Java
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_Profile;
 import java.io.InputStream;
+import java.awt.Color;
 
 // FOP
-import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.apps.FOUserAgent;
 
 /**
@@ -117,9 +117,9 @@ public abstract class AbstractFopImage implements FopImage {
     protected boolean isTransparent = false;
 
     /**
-     * Transparent color (org.apache.fop.pdf.PDFColor).
+     * Transparent color (java.awt.Color).
      */
-    protected PDFColor transparentColor = null;
+    protected Color transparentColor = null;
 
     /**
      * Constructor.
@@ -290,9 +290,9 @@ public abstract class AbstractFopImage implements FopImage {
 
     /**
      * Return the transparent color.
-     * @return the transparent color (org.apache.fop.pdf.PDFColor)
+     * @return the transparent color (java.awt.Color)
      */
-    public PDFColor getTransparentColor() {
+    public Color getTransparentColor() {
         return this.transparentColor;
     }
 
index 8b60971b6822eae1debcc36328203ab724970457..20ad519d16e852a4c95fd001178db23d76486f86 100644 (file)
@@ -53,8 +53,8 @@ package org.apache.fop.image;
 import java.io.InputStream;
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_Profile;
+import java.awt.Color;
 
-import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.apps.FOUserAgent;
 
 /**
@@ -139,7 +139,7 @@ public interface FopImage {
      * @return the transparent color
      * (todo) Remove the PDF dependency
      */
-    PDFColor getTransparentColor();
+    Color getTransparentColor();
 
     /**
      * Indicates whether the image has a Soft Mask (See section 7.5.4 in the
index 82ea254312efba1f53da5034e29d94bdbb1e19bd..8d4d4735b62d17a82be6be295066f54013ba9958 100644 (file)
@@ -3,34 +3,34 @@
  * ============================================================================
  *                    The Apache Software License, Version 1.1
  * ============================================================================
- * 
+ *
  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without modifica-
  * tion, are permitted provided that the following conditions are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice,
  *    this list of conditions and the following disclaimer.
- * 
+ *
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution, if any, must
  *    include the following acknowledgment: "This product includes software
  *    developed by the Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself, if
  *    and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  *    endorse or promote products derived from this software without prior
  *    written permission. For written permission, please contact
  *    apache@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache", nor may
  *    "Apache" appear in their name, without prior written permission of the
  *    Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * ============================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many individuals
  * on behalf of the Apache Software Foundation and was originally created by
  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  * Software Foundation, please see <http://www.apache.org/>.
- */ 
+ */
 package org.apache.fop.image;
 
 // Java
@@ -55,12 +55,12 @@ import java.awt.image.ImageProducer;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.color.ColorSpace;
+import java.awt.Color;
 import java.io.InputStream;
 import java.io.IOException;
 import java.net.URLConnection;
 
 // FOP
-import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.apps.FOUserAgent;
 
 /**
@@ -128,7 +128,7 @@ public class GifImage extends AbstractFopImage {
             if (cm.hasAlpha()) {
                 // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
                 int transparencyType = cm.getTransparency();
-                
+
                 if (transparencyType == java.awt.Transparency.OPAQUE) {
                     this.isTransparent = false;
                 } else if (transparencyType == java.awt.Transparency.BITMASK) {
@@ -148,7 +148,7 @@ public class GifImage extends AbstractFopImage {
                                 i++) {
                             if ((alphas[i] & 0xFF) == 0) {
                                 this.isTransparent = true;
-                                this.transparentColor = new PDFColor(
+                                this.transparentColor = new Color(
                                                             (int)(reds[i] & 0xFF),
                                                             (int)(greens[i] & 0xFF),
                                                             (int)(blues[i] & 0xFF));
@@ -210,7 +210,7 @@ public class GifImage extends AbstractFopImage {
      */
     protected static class DummyConnection extends URLConnection {
         private InputStream inputStream;
-        
+
         DummyConnection(InputStream is) {
             super(null);
             inputStream = is;
index ced4ccb5b411b0018a01e43b37314e4b1b53312c..52a3c487f82661e35782276d0064aa9a47f9503e 100644 (file)
@@ -3,34 +3,34 @@
  * ============================================================================
  *                    The Apache Software License, Version 1.1
  * ============================================================================
- * 
+ *
  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without modifica-
  * tion, are permitted provided that the following conditions are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice,
  *    this list of conditions and the following disclaimer.
- * 
+ *
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution, if any, must
  *    include the following acknowledgment: "This product includes software
  *    developed by the Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself, if
  *    and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  *    endorse or promote products derived from this software without prior
  *    written permission. For written permission, please contact
  *    apache@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache", nor may
  *    "Apache" appear in their name, without prior written permission of the
  *    Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * ============================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many individuals
  * on behalf of the Apache Software Foundation and was originally created by
  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  * Software Foundation, please see <http://www.apache.org/>.
- */ 
+ */
 package org.apache.fop.image;
 
 // AWT
@@ -55,6 +55,7 @@ import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.image.BufferedImage;
 import java.awt.color.ColorSpace;
+import java.awt.Color;
 
 // JAI
 import javax.media.jai.JAI;
@@ -62,9 +63,6 @@ import javax.media.jai.RenderedOp;
 // Sun codec
 import com.sun.media.jai.codec.FileCacheSeekableStream;
 
-// FOP
-import org.apache.fop.pdf.PDFColor;
-
 /**
  * FopImage object using JAI.
  * @author Eric SCHAEFFER
@@ -100,7 +98,7 @@ public class JAIImage extends AbstractFopImage {
             if (cm.hasAlpha()) {
                 // java.awt.Transparency. BITMASK or OPAQUE or TRANSLUCENT
                 int transparencyType = cm.getTransparency();
-                
+
                 if (transparencyType == java.awt.Transparency.OPAQUE) {
                     this.isTransparent = false;
                 } else if (transparencyType == java.awt.Transparency.BITMASK) {
@@ -123,7 +121,7 @@ public class JAIImage extends AbstractFopImage {
                                 i++) {
                             if ((alphas[i] & 0xFF) == 0) {
                                 this.isTransparent = true;
-                                this.transparentColor = new PDFColor(
+                                this.transparentColor = new Color(
                                                             (int)(reds[i] & 0xFF),
                                                             (int)(greens[i] & 0xFF),
                                                             (int)(blues[i] & 0xFF));
@@ -137,7 +135,7 @@ public class JAIImage extends AbstractFopImage {
                          * for (int i = 0; i < this.width * this.height; i++) {
                          * if (cm.getAlpha(tmpMap[i]) == 0) {
                          * this.isTransparent = true;
-                         * this.transparentColor = new PDFColor(cm.getRed(tmpMap[i]), 
+                         * this.transparentColor = new PDFColor(cm.getRed(tmpMap[i]),
                          * cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
                          * break;
                          * }
index d39c2a601c06708f29be139bf52393fe9e7c0f63..417ccb40d576a94cc40014fb4ac6f5864fffbe80 100644 (file)
@@ -3,34 +3,34 @@
  * ============================================================================
  *                    The Apache Software License, Version 1.1
  * ============================================================================
- * 
+ *
  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without modifica-
  * tion, are permitted provided that the following conditions are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice,
  *    this list of conditions and the following disclaimer.
- * 
+ *
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution, if any, must
  *    include the following acknowledgment: "This product includes software
  *    developed by the Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself, if
  *    and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  *    endorse or promote products derived from this software without prior
  *    written permission. For written permission, please contact
  *    apache@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache", nor may
  *    "Apache" appear in their name, without prior written permission of the
  *    Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * ============================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many individuals
  * on behalf of the Apache Software Foundation and was originally created by
  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  * Software Foundation, please see <http://www.apache.org/>.
- */ 
+ */
 package org.apache.fop.image;
 
 // Java
@@ -55,6 +55,7 @@ import java.awt.image.ImageProducer;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.color.ColorSpace;
+import java.awt.Color;
 
 // Jimi
 import com.sun.jimi.core.Jimi;
@@ -63,7 +64,6 @@ import com.sun.jimi.core.Jimi;
 import org.apache.avalon.framework.logger.Logger;
 
 // FOP
-import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.apps.FOUserAgent;
 
 /**
@@ -157,7 +157,7 @@ public class JimiImage extends AbstractFopImage {
                                 i++) {
                             if ((alphas[i] & 0xFF) == 0) {
                                 this.isTransparent = true;
-                                this.transparentColor = new PDFColor(
+                                this.transparentColor = new Color(
                                                             (int)(reds[i] & 0xFF),
                                                             (int)(greens[i] & 0xFF),
                                                             (int)(blues[i] & 0xFF));
@@ -171,7 +171,7 @@ public class JimiImage extends AbstractFopImage {
                          * for (int i = 0; i < this.width * this.height; i++) {
                          * if (cm.getAlpha(tmpMap[i]) == 0) {
                          * this.isTransparent = true;
-                         * this.transparentColor = new PDFColor(cm.getRed(tmpMap[i]), 
+                         * this.transparentColor = new PDFColor(cm.getRed(tmpMap[i]),
                          *      cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
                          * break;
                          * }
index e90e903158eeb5f90d07034f250e0f52c6309f60..325a2da15240446bfcb1d172305fa5b16cbc797e 100644 (file)
@@ -3,34 +3,34 @@
  * ============================================================================
  *                    The Apache Software License, Version 1.1
  * ============================================================================
- * 
+ *
  * Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without modifica-
  * tion, are permitted provided that the following conditions are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright notice,
  *    this list of conditions and the following disclaimer.
- * 
+ *
  * 2. Redistributions in binary form must reproduce the above copyright notice,
  *    this list of conditions and the following disclaimer in the documentation
  *    and/or other materials provided with the distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution, if any, must
  *    include the following acknowledgment: "This product includes software
  *    developed by the Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself, if
  *    and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "FOP" and "Apache Software Foundation" must not be used to
  *    endorse or promote products derived from this software without prior
  *    written permission. For written permission, please contact
  *    apache@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache", nor may
  *    "Apache" appear in their name, without prior written permission of the
  *    Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  * ============================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many individuals
  * on behalf of the Apache Software Foundation and was originally created by
  * James Tauber <jtauber@jtauber.com>. For more information on the Apache
  * Software Foundation, please see <http://www.apache.org/>.
- */ 
+ */
 package org.apache.fop.render.pdf;
 
 import org.apache.fop.pdf.PDFFilterList;
@@ -72,7 +72,7 @@ import java.awt.color.ICC_Profile;
  * PDFImage implementation for the PDF renderer.
  */
 public class FopPDFImage implements PDFImage {
-    
+
     private FopImage fopImage;
     private PDFICCStream pdfICCStream = null;
     private PDFFilter pdfFilter = null;
@@ -131,7 +131,7 @@ public class FopPDFImage implements PDFImage {
     public boolean isDCT() {
         return fopImage.getMimeType().equals("image/jpeg");
     }
-    
+
     /**
      * @see org.apache.fop.pdf.PDFImage#getWidth()
      */
@@ -172,7 +172,9 @@ public class FopPDFImage implements PDFImage {
      * @see org.apache.fop.pdf.PDFImage#getTransparentColor()
      */
     public PDFColor getTransparentColor() {
-        return fopImage.getTransparentColor();
+        return new PDFColor(fopImage.getTransparentColor().getRed(),
+                            fopImage.getTransparentColor().getGreen(),
+                            fopImage.getTransparentColor().getBlue());
     }
 
     /**
@@ -229,7 +231,7 @@ public class FopPDFImage implements PDFImage {
         preamble.append((double)(1f / (double) bboxw) + " "
                       + (double)(1f / (double) bboxh) + " scale\n");
         preamble.append(-bbox[0] + " " + (-bbox[1]) + " translate\n");
-        preamble.append(bbox[0] + " " + bbox[1] + " " 
+        preamble.append(bbox[0] + " " + bbox[1] + " "
                         + bboxw + " " + bboxh + " rectclip\n");
         preamble.append("newpath\n");
 
@@ -279,7 +281,7 @@ public class FopPDFImage implements PDFImage {
         }
         return pdfCS;
     }
-    
+
     /**
      * @see org.apache.fop.pdf.PDFImage#getFilterHint()
      */