pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1828715 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Date Mon, 09 Apr 2018 13:38:14 GMT
Author: tilman
Date: Mon Apr  9 13:38:14 2018
New Revision: 1828715

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

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

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java?rev=1828715&r1=1828714&r2=1828715&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Mon Apr  9 13:38:14 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;
@@ -184,9 +185,12 @@ public final class LosslessFactory
         else
         {
             bpc = 8;
+            int dataType = alphaRaster.getDataBuffer().getDataType();
+            // for 16 it images we need to 
+            int shift = dataType == DataBuffer.TYPE_USHORT ? 8 : 0;
             for (int pixel : pixels)
             {
-                bos.write(pixel);
+                bos.write(pixel >>> shift);
             }
         }
 



Mime
View raw message