pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1728204 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
Date Tue, 02 Feb 2016 20:29:13 GMT
Author: tilman
Date: Tue Feb  2 20:29:12 2016
New Revision: 1728204

URL: http://svn.apache.org/viewvc?rev=1728204&view=rev
Log:
PDFBOX-3221: optimize transfer function with arrays

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java?rev=1728204&r1=1728203&r2=1728204&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/rendering/PageDrawer.java Tue Feb
 2 20:29:12 2016
@@ -834,9 +834,7 @@ public class PageDrawer extends PDFGraph
         WritableRaster raster = image.copyData(image.getRaster().createCompatibleWritableRaster());
         BufferedImage bim = new BufferedImage(cm, raster, isAlphaPremultiplied, null);
 
-        Map<Integer, Integer> rMap;
-        Map<Integer, Integer> gMap;
-        Map<Integer, Integer> bMap;
+        Integer rMap[], gMap[], bMap[];
         PDFunction rf, gf, bf;
         if (transfer instanceof COSArray)
         {
@@ -844,14 +842,14 @@ public class PageDrawer extends PDFGraph
             rf = PDFunction.create(ar.getObject(0));
             gf = PDFunction.create(ar.getObject(1));
             bf = PDFunction.create(ar.getObject(2));
-            rMap = new HashMap<Integer, Integer>(256);
-            gMap = new HashMap<Integer, Integer>(256);
-            bMap = new HashMap<Integer, Integer>(256);
+            rMap = new Integer[256];
+            gMap = new Integer[256];
+            bMap = new Integer[256];
         }
         else
         {
             rf = gf = bf = PDFunction.create(transfer);
-            rMap = gMap = bMap = new HashMap<Integer, Integer>(256);
+            rMap = gMap = bMap = new Integer[256];
         }
         float input[] = new float[1];
         for (int x = 0; x < image.getWidth(); ++x)
@@ -859,39 +857,39 @@ public class PageDrawer extends PDFGraph
             for (int y = 0; y < image.getHeight(); ++y)
             {
                 int rgb = image.getRGB(x, y);
-                Integer ri = (rgb >> 16) & 0xFF;
-                Integer gi = (rgb >> 8) & 0xFF;
-                Integer bi = rgb & 0xFF;
+                int ri = (rgb >> 16) & 0xFF;
+                int gi = (rgb >> 8) & 0xFF;
+                int bi = rgb & 0xFF;
                 int ro, go, bo;
-                if (rMap.containsKey(ri))
+                if (rMap[ri] != null)
                 {
-                    ro = rMap.get(ri);
+                    ro = rMap[ri];
                 }
                 else
                 {
                     input[0] = (ri & 0xFF) / 255f;
                     ro = (int) (rf.eval(input)[0] * 255);
-                    rMap.put(ri, ro);
+                    rMap[ri] = ro;
                 }
-                if (gMap.containsKey(gi))
+                if (gMap[gi] != null)
                 {
-                    go = gMap.get(gi);
+                    go = gMap[gi];
                 }
                 else
                 {
                     input[0] = (gi & 0xFF) / 255f;
                     go = (int) (gf.eval(input)[0] * 255);
-                    gMap.put(gi, go);
+                    gMap[gi] = go;
                 }
-                if (bMap.containsKey(bi))
+                if (bMap[bi] != null)
                 {
-                    bo = bMap.get(bi);
+                    bo = bMap[bi];
                 }
                 else
                 {
                     input[0] = (bi & 0xFF) / 255f;
                     bo = (int) (bf.eval(input)[0] * 255);
-                    bMap.put(bi, bo);
+                    bMap[bi] = bo;
                 }
                 bim.setRGB(x, y, (rgb & 0xFF000000) | (ro << 16) | (go <<
8) | bo);
             }



Mime
View raw message