]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Support for soft masks (transparency) with ImageIO image adapter. Should help with...
authorJeremias Maerki <jeremias@apache.org>
Sat, 3 Feb 2007 22:22:26 +0000 (22:22 +0000)
committerJeremias Maerki <jeremias@apache.org>
Sat, 3 Feb 2007 22:22:26 +0000 (22:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@503323 13f79535-47bb-0310-9956-ffa450edef68

src/java-1.4/org/apache/fop/image/ImageIOImage.java
status.xml

index 463331530335cb752311cbb820e26b7c6a8b72cc..ebb4a09eb4e5bacb244b679f20a0253c750dbbf1 100644 (file)
@@ -46,6 +46,8 @@ import org.w3c.dom.NodeList;
  */
 public class ImageIOImage extends AbstractFopImage {
 
+    private byte[] softMask = null;
+
     /**
      * Creates a new ImageIOImage.
      * @param info the image info from the ImageReader
@@ -163,22 +165,14 @@ public class ImageIOImage extends AbstractFopImage {
                             }
                         }
                     } else {
-                        // TRANSLUCENT
-                        /*
-                         * this.isTransparent = false;
-                         * 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]), 
-                         * cm.getGreen(tmpMap[i]), cm.getBlue(tmpMap[i]));
-                         * break;
-                         * }
-                         * }
-                         * // or use special API...
-                         */
+                        //TODO Is there another case?
                         this.isTransparent = false;
                     }
                 } else {
+                    // TRANSLUCENT
+                    this.softMask = new byte[width * height];
+                    imageData.getAlphaRaster().getDataElements(
+                            0, 0, width, height, this.softMask);
                     this.isTransparent = false;
                 }
             } else {
@@ -217,5 +211,23 @@ public class ImageIOImage extends AbstractFopImage {
         return loadDefaultOriginalData();
     }
     
+    /** @see org.apache.fop.image.FopImage#hasSoftMask() */
+    public boolean hasSoftMask() {
+        if (this.bitmaps == null && this.raw == null) {
+            loadBitmap();
+        }
+
+        return (this.softMask != null);
+    }
+
+    /** @see org.apache.fop.image.FopImage#getSoftMask() */
+    public byte[] getSoftMask() {
+        if (this.bitmaps == null) {
+            loadBitmap();
+        }
+
+        return this.softMask;
+    }
+
 }
 
index 8b2ab81271ae6542270d33a65a645552f2fa4f25..5e11e4247a9d976a7af8b719ad1d7e54d7b0ee0d 100644 (file)
@@ -28,6 +28,9 @@
 
   <changes>
     <release version="FOP Trunk">
+      <action context="Code" dev="JM" type="add">
+        Support for soft masks (transparency) with ImageIO image adapter.
+      </action>
       <action context="Code" dev="LF" type="fix" fixes-bug="41019">
         Fix incorrect behaviour of the BreakingAlgorithm when some inline content is wider than
         the available ipd, causing a restart.