Author: tilman
Date: Mon Apr  9 13:38:19 2018
New Revision: 1828716

URL: http://svn.apache.org/viewvc?rev=1828716&view=rev
Log:
PDFBOX-4184: divide 16 bit alpha values by 256

Modified:
    
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java

Modified: 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: 
http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1828716&r1=1828715&r2=1828716&view=diff
==============================================================================
--- 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
 (original)
+++ 
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
 Mon Apr  9 13:38:19 2018
@@ -17,6 +17,7 @@ package org.apache.pdfbox.pdmodel.graphi
 
 import java.awt.Transparency;
 import java.awt.image.BufferedImage;
+import java.awt.image.DataBuffer;
 import java.awt.image.WritableRaster;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -183,9 +184,11 @@ public final class LosslessFactory
         else
         {
             bpc = 8;
+            int dataType = alphaRaster.getDataBuffer().getDataType();
+            int shift = dataType == DataBuffer.TYPE_USHORT ? 8 : 0;
             for (int pixel : pixels)
             {
-                bos.write(pixel);
+                bos.write(pixel >>> shift);
             }
         }
 


Reply via email to