pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1828916 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/image/LosslessFactory.java
Date Wed, 11 Apr 2018 17:30:48 GMT
Author: tilman
Date: Wed Apr 11 17:30:48 2018
New Revision: 1828916

URL: http://svn.apache.org/viewvc?rev=1828916&view=rev
Log:
PDFBOX-4187: simplify code

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=1828916&r1=1828915&r2=1828916&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
Wed Apr 11 17:30:48 2018
@@ -64,15 +64,14 @@ public final class LosslessFactory
         }      
     }
 
+    // grayscale images need one color per sample
     private static PDImageXObject createFromGrayImage(BufferedImage image, PDDocument document)
             throws IOException
     {
         int height = image.getHeight();
         int width = image.getWidth();
         int[] rgbLineBuffer = new int[width];
-        int bpc;
-        // grayscale images need one color per sample
-        bpc = image.getColorModel().getPixelSize();
+        int bpc = image.getColorModel().getPixelSize();
         ByteArrayOutputStream baos = new ByteArrayOutputStream(((width*bpc/8)+(width*bpc%8
!= 0 ? 1:0))*height);
         MemoryCacheImageOutputStream mcios = new MemoryCacheImageOutputStream(baos);
         for (int y = 0; y < height; ++y)
@@ -144,14 +143,12 @@ public final class LosslessFactory
                     }
                 }
             }
-            if (transparency == Transparency.BITMASK)
+
+            // skip boundary if needed
+            if (transparency == Transparency.BITMASK && alphaBitPos != 7)
             {
-                // skip boundary if needed
-                if (alphaBitPos != 7)
-                {
-                    alphaBitPos = 7;
-                    ++alphaByteIdx;
-                }
+                alphaBitPos = 7;
+                ++alphaByteIdx;
             }
         }
         PDImageXObject pdImage = prepareImageXObject(document, imageData,



Mime
View raw message