Author: mehdi
Date: Wed Jun 20 13:31:51 2012
New Revision: 1352095

URL: http://svn.apache.org/viewvc?rev=1352095&view=rev
Log:
Merged with trunk@1351540

Added:
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/ImageRawPNGAdapter.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawPNG.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/pdf/PDFImageHandlerRawPNG.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/ImageEncoderPNG.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRawPNG.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSImageHandlerRawPNG.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/RawPNGTestUtil.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/RawPNGTestUtil.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/pdf/ImageRawPNGAdapterTestCase.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java
      - copied unchanged from r1351540, 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/ImageEncoderPNGTestCase.java
Modified:
    xmlgraphics/fop/branches/Temp_URI_Unification/   (props changed)
    xmlgraphics/fop/branches/Temp_URI_Unification/findbugs-exclude.xml
    
xmlgraphics/fop/branches/Temp_URI_Unification/lib/xmlgraphics-commons-1.5svn.jar
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/configuration.xml
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/graphics.xml
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/META-INF/services/org.apache.fop.render.ImageHandler
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/afp/apps/ 
  (props changed)
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/afp/parser/
   (props changed)
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/pdf/BitmapImage.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java
    
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/util/ColorExt.java
   (props changed)
    xmlgraphics/fop/branches/Temp_URI_Unification/status.xml

Propchange: xmlgraphics/fop/branches/Temp_URI_Unification/
------------------------------------------------------------------------------
  Merged /xmlgraphics/fop/trunk:r1348857-1351540

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/findbugs-exclude.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/findbugs-exclude.xml?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/findbugs-exclude.xml 
(original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/findbugs-exclude.xml Wed Jun 
20 13:31:51 2012
@@ -5162,4 +5162,41 @@
      <Method name="getNonEmptyLevels"/>
      <Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS"/>
    </Match>
+   <Match>
+     <Class name="org.apache.fop.render.pdf.AbstractImageAdapter"/>
+     <Method name="populateXObjectDictionaryForIndexColorModel"/>
+     <Bug pattern="OS_OPEN_STREAM"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.render.pdf.ImageRawPNGAdapter"/>
+     <Or>
+       <Method name="outputContents"/>
+       <Method name="setup"/>
+     </Or>
+     <Or>
+       <Bug pattern="OS_OPEN_STREAM"/>
+       <Bug pattern="OS_OPEN_STREAM_EXCEPTION_PATH"/>
+     </Or>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.render.ps.ImageEncoderPNG"/>
+     <Method name="writeTo"/>
+     <Bug pattern="OS_OPEN_STREAM"/>
+   </Match>
+   <Match>
+     <Or>
+       <Class name="org.apache.fop.render.pdf.PDFImageHandlerRawPNG"/>
+       <Class name="org.apache.fop.render.ps.PSImageHandlerRawPNG"/>
+     </Or>
+     <Method name="getSupportedImageFlavors"/>
+     <Bug pattern="EI_EXPOSE_REP"/>
+   </Match>
+   <Match>
+     <Class name="org.apache.fop.render.ps.PSImageHandlerRawPNG"/>
+     <Or>
+       <Method name="handleImage"/>
+       <Method name="generateForm"/>
+     </Or>
+     <Bug pattern="BC_UNCONFIRMED_CAST"/>
+   </Match>
 </FindBugsFilter>

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/lib/xmlgraphics-commons-1.5svn.jar
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/lib/xmlgraphics-commons-1.5svn.jar?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
Binary files - no diff available.

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/configuration.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/configuration.xml?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/configuration.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/configuration.xml
 Wed Jun 20 13:31:51 2012
@@ -281,6 +281,24 @@
       treated as zero penalty in most cases. For more details on the image 
loading framework,
       please consult the documentation there.
     </p>
+    <p>
+      The ImageLoaderPNG and ImageLoaderRawPNG have a hard-coded penalty of 
1000 and as such the
+      ImageLoaderImageIO image loader will be selected by default when loading 
PNGs unless
+      the latter is disabled by awarding a INFINITE penalty to it, or one of 
the former two is 
+      promoted by awarding a strong negative penalty (say, -10000) to it.
+    </p>
+    <source><![CDATA[<fop version="1.0">
+  [..]
+  <image-loading>
+    <penalty value="-10000"
+      class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderRawPNG"/>
+    <penalty value="INFINITE"
+      class="org.apache.xmlgraphics.image.loader.impl.ImageLoaderPNG"/>
+    <penalty value="INFINITE"
+      
class="org.apache.xmlgraphics.image.loader.impl.imageio.ImageLoaderImageIO"/>
+  </image-loading>
+  <renderers....
+</fop>]]></source>
   </section>
   <section id="renderers">
     <title>Renderer configuration</title>

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/graphics.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/graphics.xml?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/graphics.xml
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/documentation/content/xdocs/trunk/graphics.xml
 Wed Jun 20 13:31:51 2012
@@ -108,7 +108,7 @@
         <tr>
           <td><a href="#png">PNG</a> (Portable Network Graphic)</td>
           <td>bitmap</td>
-          <td/>
+          <td>(X)</td>
           <td/>
           <td>X</td>
         </tr>
@@ -217,8 +217,8 @@
           </tr>
           <tr>
             <td><a href="#png">PNG</a> (Portable Network Graphic)</td>
-            <td>X</td>
-            <td>X</td>
+            <td>X [2]</td>
+            <td>X [2]</td>
             <td>X</td>
             <td>X</td>
             <td>X</td>
@@ -383,8 +383,11 @@
       <section id="png">
         <title>PNG</title>
         <p>
-          PNG images are supported through an Image&amp;nbsp;I/O codec. 
Transparency is supported but
-          not guaranteed to work with every output format.
+          FOP native support of PNG only includes the variants with 8 bits per 
channel and without
+          interlacing. Native support requires using the ImageLoaderRawPNG 
image loader.
+          Support through a Image I/O codec can use either the internal XGC 
PNG codec or the JRE PNG
+          codec. The associated image loaders are, respectively, 
ImageLoaderPNG and ImageLoaderImageIO. 
+          Transparency is supported but not guaranteed to work with every 
output format.
         </p>
       </section>
       <section id="svg">

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/META-INF/services/org.apache.fop.render.ImageHandler
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/META-INF/services/org.apache.fop.render.ImageHandler?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/META-INF/services/org.apache.fop.render.ImageHandler
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/META-INF/services/org.apache.fop.render.ImageHandler
 Wed Jun 20 13:31:51 2012
@@ -1,6 +1,7 @@
 org.apache.fop.render.pdf.PDFImageHandlerGraphics2D
 org.apache.fop.render.pdf.PDFImageHandlerRenderedImage
 org.apache.fop.render.pdf.PDFImageHandlerRawJPEG
+org.apache.fop.render.pdf.PDFImageHandlerRawPNG
 org.apache.fop.render.pdf.PDFImageHandlerRawCCITTFax
 org.apache.fop.render.pdf.PDFImageHandlerSVG
 org.apache.fop.render.java2d.Java2DImageHandlerRenderedImage
@@ -11,6 +12,7 @@ org.apache.fop.render.ps.PSImageHandlerR
 org.apache.fop.render.ps.PSImageHandlerEPS
 org.apache.fop.render.ps.PSImageHandlerRawCCITTFax
 org.apache.fop.render.ps.PSImageHandlerRawJPEG
+org.apache.fop.render.ps.PSImageHandlerRawPNG
 org.apache.fop.render.ps.PSImageHandlerGraphics2D
 org.apache.fop.render.ps.PSImageHandlerSVG
 org.apache.fop.render.afp.AFPImageHandlerRenderedImage

Propchange: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/afp/apps/
------------------------------------------------------------------------------
  Merged 
/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:r1348857-1351540

Propchange: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/afp/parser/
------------------------------------------------------------------------------
  Merged 
/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/parser:r1348857-1351540

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/fo/properties/CondLengthProperty.java?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/fo/properties/CondLengthProperty.java
 Wed Jun 20 13:31:51 2012
@@ -26,6 +26,7 @@ import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.PropertyException;
+import org.apache.fop.util.CompareUtil;
 
 /**
  * Superclass for properties that have conditional lengths
@@ -192,8 +193,8 @@ public class CondLengthProperty extends 
 
         if (obj instanceof CondLengthProperty) {
             CondLengthProperty clp = (CondLengthProperty)obj;
-            return (this.length == clp.length
-                    && this.conditionality == clp.conditionality);
+            return (CompareUtil.equal(this.length, clp.length)
+                    && CompareUtil.equal(this.conditionality, 
clp.conditionality));
         }
         return false;
     }

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/pdf/BitmapImage.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/pdf/BitmapImage.java?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/pdf/BitmapImage.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/pdf/BitmapImage.java
 Wed Jun 20 13:31:51 2012
@@ -37,6 +37,7 @@ public class BitmapImage implements PDFI
     private PDFColor transparent = null;
     private String key;
     private PDFDocument pdfDoc;
+    private PDFFilter pdfFilter;
 
     /**
      * Create a bitmap image.
@@ -208,9 +209,12 @@ public class BitmapImage implements PDFI
      * {@inheritDoc}
      */
     public PDFFilter getPDFFilter() {
-        return null;
+        return pdfFilter;
     }
 
+    public void setPDFFilter(PDFFilter pdfFilter) {
+        this.pdfFilter = pdfFilter;
+    }
 }
 
 

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/AbstractImageAdapter.java
 Wed Jun 20 13:31:51 2012
@@ -20,13 +20,16 @@
 package org.apache.fop.render.pdf;
 import java.awt.color.ColorSpace;
 import java.awt.color.ICC_Profile;
+import java.awt.image.IndexColorModel;
 
+import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.java2d.color.profile.ColorProfileUtil;
 
+import org.apache.fop.pdf.PDFArray;
 import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.pdf.PDFConformanceException;
 import org.apache.fop.pdf.PDFDeviceColorSpace;
@@ -50,7 +53,9 @@ public abstract class AbstractImageAdapt
     /** the image */
     protected Image image;
 
-    private PDFICCStream pdfICCStream = null;
+    private PDFICCStream pdfICCStream;
+
+    private static final int MAX_HIVAL = 255;
 
     /**
      * Creates a new PDFImage from an Image instance.
@@ -203,6 +208,68 @@ public abstract class AbstractImageAdapt
     }
 
     /**
+     * This is to be used by populateXObjectDictionary() when the image is 
palette based.
+     * @param dict the dictionary to fill in
+     * @param icm the image color model
+     */
+    protected void populateXObjectDictionaryForIndexColorModel(PDFDictionary 
dict, IndexColorModel icm) {
+        PDFArray indexed = new PDFArray(dict);
+        indexed.add(new PDFName("Indexed"));
+        if (icm.getColorSpace().getType() != ColorSpace.TYPE_RGB) {
+            log.warn("Indexed color space is not using RGB as base color 
space."
+                    + " The image may not be handled correctly." + " Base 
color space: "
+                    + icm.getColorSpace() + " Image: " + image.getInfo());
+        }
+        indexed.add(new 
PDFName(toPDFColorSpace(icm.getColorSpace()).getName()));
+        int c = icm.getMapSize();
+        int hival = c - 1;
+        if (hival > MAX_HIVAL) {
+            throw new UnsupportedOperationException("hival must not go beyond 
" + MAX_HIVAL);
+        }
+        indexed.add(Integer.valueOf(hival));
+        int[] palette = new int[c];
+        icm.getRGBs(palette);
+        ByteArrayOutputStream baout = new ByteArrayOutputStream();
+        for (int i = 0; i < c; i++) {
+            // TODO Probably doesn't work for non RGB based color spaces
+            // See log warning above
+            int entry = palette[i];
+            baout.write((entry & 0xFF0000) >> 16);
+            baout.write((entry & 0xFF00) >> 8);
+            baout.write(entry & 0xFF);
+        }
+        indexed.add(baout.toByteArray());
+
+        dict.put("ColorSpace", indexed);
+        dict.put("BitsPerComponent", icm.getPixelSize());
+
+        Integer index = getIndexOfFirstTransparentColorInPalette(icm);
+        if (index != null) {
+            PDFArray mask = new PDFArray(dict);
+            mask.add(index);
+            mask.add(index);
+            dict.put("Mask", mask);
+        }
+    }
+
+    private static Integer 
getIndexOfFirstTransparentColorInPalette(IndexColorModel icm) {
+        byte[] alphas = new byte[icm.getMapSize()];
+        byte[] reds = new byte[icm.getMapSize()];
+        byte[] greens = new byte[icm.getMapSize()];
+        byte[] blues = new byte[icm.getMapSize()];
+        icm.getAlphas(alphas);
+        icm.getReds(reds);
+        icm.getGreens(greens);
+        icm.getBlues(blues);
+        for (int i = 0; i < icm.getMapSize(); i++) {
+            if ((alphas[i] & 0xFF) == 0) {
+                return Integer.valueOf(i);
+            }
+        }
+        return null;
+    }
+
+    /**
      * Converts a ColorSpace object to a PDFColorSpace object.
      * @param cs ColorSpace instance
      * @return PDFColorSpace new converted object

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
 Wed Jun 20 13:31:51 2012
@@ -27,8 +27,6 @@ import java.awt.image.RenderedImage;
 import java.io.IOException;
 import java.io.OutputStream;
 
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -36,14 +34,12 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.ps.ImageEncodingHelper;
 
 import org.apache.fop.pdf.AlphaRasterImage;
-import org.apache.fop.pdf.PDFArray;
 import org.apache.fop.pdf.PDFColor;
 import org.apache.fop.pdf.PDFDeviceColorSpace;
 import org.apache.fop.pdf.PDFDictionary;
 import org.apache.fop.pdf.PDFDocument;
 import org.apache.fop.pdf.PDFFilter;
 import org.apache.fop.pdf.PDFFilterList;
-import org.apache.fop.pdf.PDFName;
 import org.apache.fop.pdf.PDFReference;
 
 /**
@@ -162,30 +158,6 @@ public class ImageRenderedAdapter extend
         return (getImage().getTransparentColor() != null);
     }
 
-    private static Integer 
getIndexOfFirstTransparentColorInPalette(RenderedImage image) {
-        ColorModel cm = image.getColorModel();
-        if (cm instanceof IndexColorModel) {
-            IndexColorModel icm = (IndexColorModel)cm;
-            //Identify the transparent color in the palette
-            byte[] alphas = new byte[icm.getMapSize()];
-            byte[] reds = new byte[icm.getMapSize()];
-            byte[] greens = new byte[icm.getMapSize()];
-            byte[] blues = new byte[icm.getMapSize()];
-            icm.getAlphas(alphas);
-            icm.getReds(reds);
-            icm.getGreens(greens);
-            icm.getBlues(blues);
-            for (int i = 0;
-                    i < ((IndexColorModel) cm).getMapSize();
-                    i++) {
-                if ((alphas[i] & 0xFF) == 0) {
-                    return Integer.valueOf(i);
-                }
-            }
-        }
-        return null;
-    }
-
     /** {@inheritDoc} */
     @Override
     public PDFColor getTransparentColor() {
@@ -230,54 +202,13 @@ public class ImageRenderedAdapter extend
         }
     }
 
-    private static final int MAX_HIVAL = 255;
-
     /** {@inheritDoc} */
     @Override
     public void populateXObjectDictionary(PDFDictionary dict) {
         ColorModel cm = getEffectiveColorModel();
         if (cm instanceof IndexColorModel) {
-            IndexColorModel icm = (IndexColorModel)cm;
-            PDFArray indexed = new PDFArray(dict);
-            indexed.add(new PDFName("Indexed"));
-
-            if (icm.getColorSpace().getType() != ColorSpace.TYPE_RGB) {
-                log.warn("Indexed color space is not using RGB as base color 
space."
-                        + " The image may not be handled correctly."
-                        + " Base color space: " + icm.getColorSpace()
-                        + " Image: " + image.getInfo());
-            }
-            indexed.add(new 
PDFName(toPDFColorSpace(icm.getColorSpace()).getName()));
-            int c = icm.getMapSize();
-            int hival = c - 1;
-            if (hival > MAX_HIVAL) {
-                throw new UnsupportedOperationException("hival must not go 
beyond " + MAX_HIVAL);
-            }
-            indexed.add(Integer.valueOf(hival));
-            int[] palette = new int[c];
-            icm.getRGBs(palette);
-            ByteArrayOutputStream baout = new ByteArrayOutputStream();
-            for (int i = 0; i < c; i++) {
-                //TODO Probably doesn't work for non RGB based color spaces
-                //See log warning above
-                int entry = palette[i];
-                baout.write((entry & 0xFF0000) >> 16);
-                baout.write((entry & 0xFF00) >> 8);
-                baout.write(entry & 0xFF);
-            }
-            indexed.add(baout.toByteArray());
-            IOUtils.closeQuietly(baout);
-
-            dict.put("ColorSpace", indexed);
-            dict.put("BitsPerComponent", icm.getPixelSize());
-
-            Integer index = 
getIndexOfFirstTransparentColorInPalette(getImage().getRenderedImage());
-            if (index != null) {
-                PDFArray mask = new PDFArray(dict);
-                mask.add(index);
-                mask.add(index);
-                dict.put("Mask", mask);
-            }
+            IndexColorModel icm = (IndexColorModel) cm;
+            super.populateXObjectDictionaryForIndexColorModel(dict, icm);
         }
     }
 

Modified: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java
 (original)
+++ 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/render/ps/PSImageHandlerRenderedImage.java
 Wed Jun 20 13:31:51 2012
@@ -19,7 +19,10 @@
 
 package org.apache.fop.render.ps;
 
+import java.awt.Dimension;
 import java.awt.Rectangle;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.ColorModel;
 import java.awt.image.RenderedImage;
 import java.io.IOException;
 
@@ -28,6 +31,8 @@ import org.apache.xmlgraphics.image.load
 import org.apache.xmlgraphics.image.loader.ImageInfo;
 import org.apache.xmlgraphics.image.loader.impl.ImageRendered;
 import org.apache.xmlgraphics.ps.FormGenerator;
+import org.apache.xmlgraphics.ps.ImageEncoder;
+import org.apache.xmlgraphics.ps.ImageEncodingHelper;
 import org.apache.xmlgraphics.ps.ImageFormGenerator;
 import org.apache.xmlgraphics.ps.PSGenerator;
 import org.apache.xmlgraphics.ps.PSImageUtils;
@@ -47,17 +52,24 @@ public class PSImageHandlerRenderedImage
     /** {@inheritDoc} */
     public void handleImage(RenderingContext context, Image image, Rectangle 
pos)
                 throws IOException {
-        PSRenderingContext psContext = (PSRenderingContext)context;
+        PSRenderingContext psContext = (PSRenderingContext) context;
         PSGenerator gen = psContext.getGenerator();
-        ImageRendered imageRend = (ImageRendered)image;
+        ImageRendered imageRend = (ImageRendered) image;
 
-        float x = (float)pos.getX() / 1000f;
-        float y = (float)pos.getY() / 1000f;
-        float w = (float)pos.getWidth() / 1000f;
-        float h = (float)pos.getHeight() / 1000f;
+        float x = (float) pos.getX() / 1000f;
+        float y = (float) pos.getY() / 1000f;
+        float w = (float) pos.getWidth() / 1000f;
+        float h = (float) pos.getHeight() / 1000f;
+        Rectangle2D targetRect = new Rectangle2D.Double(x, y, w, h);
 
         RenderedImage ri = imageRend.getRenderedImage();
-        PSImageUtils.renderBitmapImage(ri, x, y, w, h, gen);
+        ImageEncoder encoder = 
ImageEncodingHelper.createRenderedImageEncoder(ri);
+        Dimension imgDim = new Dimension(ri.getWidth(), ri.getHeight());
+        String imgDescription = ri.getClass().getName();
+        ImageEncodingHelper helper = new ImageEncodingHelper(ri);
+        ColorModel cm = helper.getEncodedColorModel();
+
+        PSImageUtils.writeImage(encoder, imgDim, imgDescription, targetRect, 
cm, gen);
     }
 
     /** {@inheritDoc} */

Propchange: 
xmlgraphics/fop/branches/Temp_URI_Unification/src/java/org/apache/fop/util/ColorExt.java
------------------------------------------------------------------------------
  Merged 
/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:r1348857-1351540

Modified: xmlgraphics/fop/branches/Temp_URI_Unification/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_URI_Unification/status.xml?rev=1352095&r1=1352094&r2=1352095&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_URI_Unification/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_URI_Unification/status.xml Wed Jun 20 
13:31:51 2012
@@ -63,6 +63,18 @@
       documents. Example: the fix of marks layering will be such a case when 
it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" 
due-to="Luis Bernardo">
+        Update site documentation about PNG image loading configuration and 
support.
+      </action>
+      <action context="Images" dev="GA" type="update" fixes-bug="40676" 
due-to="Luis Bernardo">
+        Fix newly introduced findbugs warnings.
+      </action>
+      <action context="Images" dev="GA" type="fix" fixes-bug="40676" 
due-to="Luis Bernardo, Matthias Reischenbacher">
+        Support use of ImageLoaderRawPNG decoder in order to prevent 
re-encoding of PNG images (and unnecssary output file bloat).
+      </action>
+      <action context="Code" dev="GA" type="fix" fixes-bug="53412" 
due-to="Alexios Giotis">
+        Eliminate incorrect use of object identity which produces excessive 
property cache collisions.
+      </action>
       <action context="Code" dev="GA" type="fix">
         Eliminate javadocs warnings.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to