xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r603250 - /xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
Date Tue, 11 Dec 2007 14:17:34 GMT
Author: jeremias
Date: Tue Dec 11 06:17:32 2007
New Revision: 603250

URL: http://svn.apache.org/viewvc?rev=603250&view=rev
Log:
Removing failed experiment: raw PNG embedding didn't work out.

Modified:
    xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java

Modified: xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java?rev=603250&r1=603249&r2=603250&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
(original)
+++ xmlgraphics/fop/branches/Temp_ImagePackageRedesign/src/java/org/apache/fop/render/pdf/ImageRenderedAdapter.java
Tue Dec 11 06:17:32 2007
@@ -21,29 +21,22 @@
 import java.awt.color.ColorSpace;
 import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
-import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.zip.Deflater;
-import java.util.zip.DeflaterOutputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.xmlgraphics.image.codec.png.PNGEncodeParam;
-import org.apache.xmlgraphics.image.codec.png.PNGImageEncoder;
 import org.apache.xmlgraphics.ps.ImageEncodingHelper;
 
 import org.apache.fop.image2.impl.ImageRendered;
 import org.apache.fop.pdf.AlphaRasterImage;
-import org.apache.fop.pdf.FlateFilter;
 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.PDFFilterException;
 import org.apache.fop.pdf.PDFFilterList;
 import org.apache.fop.pdf.PDFName;
 import org.apache.fop.pdf.PDFReference;
@@ -62,7 +55,6 @@
     private PDFFilter pdfFilter = null;
     private String maskRef;
     private PDFReference softMask;
-    private boolean usePredictors = false;
 
     /**
      * Creates a new PDFImage from an Image instance.
@@ -96,22 +88,6 @@
         RenderedImage ri = getImage().getRenderedImage();
         ColorModel cm = getEffectiveColorModel();
 
-        if (usePredictors) {
-            //Experiment hasn't worked, yet, so it's disabled
-            FlateFilter flate;
-            try {
-                flate = new FlateFilter();
-                flate.setApplied(true);
-                flate.setPredictor(FlateFilter.PREDICTION_PNG_OPT);
-                flate.setColors(cm.getNumComponents());
-                flate.setColumns(ri.getWidth());
-                flate.setBitsPerComponent(getBitsPerComponent());
-            } catch (PDFFilterException e) {
-                throw new RuntimeException("Unexpected bug while configuring FlateFilter",
e);
-            }
-            this.pdfFilter = flate;
-        }
-
         super.setup(doc);
         
         //Handle transparency mask if applicable
@@ -123,7 +99,6 @@
             
             AlphaRasterImage alphaImage = new AlphaRasterImage("Mask:" + getKey(), ri);
             this.softMask = doc.addImage(null, alphaImage).makeReference();
-
         }
     }
 
@@ -172,12 +147,6 @@
                     i < ((IndexColorModel) cm).getMapSize();
                     i++) {
                 if ((alphas[i] & 0xFF) == 0) {
-                    /*
-                    Color transparentColor = new Color(
-                            (int)(reds[i] & 0xFF),
-                            (int)(greens[i] & 0xFF),
-                            (int)(blues[i] & 0xFF));
-                    */
                     return new Integer(i);
                 }
             }
@@ -223,14 +192,7 @@
     
     /** {@inheritDoc} */
     public void outputContents(OutputStream out) throws IOException {
-        if (usePredictors) {
-            PNGEncodeParam param = PNGEncodeParam.getDefaultEncodeParam(
-                    getImage().getRenderedImage());
-            EmbeddedPNGEncoder encoder = new EmbeddedPNGEncoder(out, param);
-            encoder.encode(getImage().getRenderedImage());
-        } else {
-            encodingHelper.encode(out);
-        }
+        encodingHelper.encode(out);
     }
 
     private static final int MAX_HIVAL = 255;
@@ -302,58 +264,7 @@
     
     /** {@inheritDoc} */
     public String getFilterHint() {
-        if (usePredictors) {
-            return PDFFilterList.PRECOMPRESSED_FILTER;
-        } else {
-            return PDFFilterList.IMAGE_FILTER;
-        }
-    }
-
-    private static class EmbeddedPNGEncoder extends PNGImageEncoder {
-
-        public EmbeddedPNGEncoder(OutputStream output, PNGEncodeParam param) {
-            super(output, param);
-        }
-        
-        public void encode(RenderedImage image) throws IOException {
-            prepareEncoding(image);
-            
-            DeflaterOutputStream dos
-                = new DeflaterOutputStream(getOutputStream(),
-                        new Deflater(Deflater.DEFAULT_COMPRESSION));
-
-            // Future work - don't convert entire image to a Raster It
-            // might seem that you could just call image.getData() but
-            // 'BufferedImage.subImage' doesn't appear to set the Width
-            // and height properly of the Child Raster, so the Raster
-            // you get back here appears larger than it should.
-            // This solves that problem by bounding the raster to the
-            // image's bounds...
-            /*
-            Raster ras = image.getData(new Rectangle(image.getMinX(), 
-                                                     image.getMinY(),
-                                                     image.getWidth(),
-                                                     image.getHeight()));
-            */
-            Raster ras = image.getData();
-
-            boolean skipAlpha = image.getColorModel().hasAlpha();
-            if (skipAlpha) {
-                int numBands = ras.getNumBands() - 1;
-                int[] bandList = new int[numBands];
-                for (int i = 0; i < numBands; i++) {
-                    bandList[i] = i;
-                }
-                ras = ras.createChild(0, 0,
-                                      ras.getWidth(), ras.getHeight(),
-                                      0, 0,
-                                      bandList);
-            }
-
-            encodePass(dos, ras, 0, 0, 1, 1);
-
-            dos.finish();
-        }
+        return PDFFilterList.IMAGE_FILTER;
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message