Author: jeremias
Date: Wed Sep 17 09:41:14 2008
New Revision: 696365

URL: http://svn.apache.org/viewvc?rev=696365&view=rev
Log:
Bugzilla #45795:
PDF Output: Added support for handling 16-bit alpha channel. They are currently 
converted to 8 bits.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java
    xmlgraphics/fop/trunk/status.xml

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java?rev=696365&r1=696364&r2=696365&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/pdf/AlphaRasterImage.java Wed 
Sep 17 09:41:14 2008
@@ -48,6 +48,9 @@
      */
     public AlphaRasterImage(String k, Raster alpha) {
         this.key = k;
+        //Enable the commented line below if 16-bit alpha channels are desired.
+        //Otherwise, we compress the alpha channel to 8 bit which should be 
sufficient.
+        //this.bitsPerComponent = alpha.getSampleModel().getSampleSize(0);
         this.bitsPerComponent = 8;
         this.colorSpace = new 
PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_GRAY);
         if (alpha == null) {
@@ -148,6 +151,18 @@
                 alpha.getDataElements(0, y, w, 1, line);
                 out.write(line);
             }
+        } else if (dataType == DataBuffer.TYPE_USHORT) {
+            short[] sline = new short[nbands * w];
+            byte[] line = new byte[nbands * w];
+            for (int y = 0; y < h; y++) {
+                alpha.getDataElements(0, y, w, 1, sline);
+                for (int i = 0; i < w; i++) {
+                    //this compresses a 16-bit alpha channel to 8 bits!
+                    //we probably don't ever need a 16-bit channel
+                    line[i] = (byte)(sline[i] >> 8);
+                }
+                out.write(line);
+            }
         } else if (dataType == DataBuffer.TYPE_INT) {
             //Is there an better way to get a 8bit raster from a TYPE_INT 
raster?
             int shift = 24;

Modified: xmlgraphics/fop/trunk/status.xml
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=696365&r1=696364&r2=696365&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Wed Sep 17 09:41:14 2008
@@ -53,6 +53,10 @@
 
   <changes>
     <release version="FOP Trunk" date="TBD">
+      <action context="Renderers" dev="JM" type="add" fixes-bug="45795">
+        PDF Output: Added support for handling 16-bit alpha channel. They are 
currently
+        converted to 8 bits.
+      </action>
       <action context="Renderers" dev="JM" type="fix">
         PDF Output: Made sure the XMP Metadata stream is never compressed.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to