pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1801276 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
Date Sat, 08 Jul 2017 11:02:18 GMT
Author: tilman
Date: Sat Jul  8 11:02:18 2017
New Revision: 1801276

URL: http://svn.apache.org/viewvc?rev=1801276&view=rev
Log:
PDFBOX-3854: return BufferedImage.TYPE_INT_RGB instead of TYPE_CUSTOM

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java?rev=1801276&r1=1801275&r2=1801276&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
Sat Jul  8 11:02:18 2017
@@ -111,6 +111,28 @@ public final class PDDeviceRGB extends P
         ColorModel colorModel = new ComponentColorModel(awtColorSpace,
                 false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType());
 
-        return new BufferedImage(colorModel, raster, false, null);
+	BufferedImage image = new BufferedImage(colorModel, raster, false, null);
+
+        //
+        // WARNING: this method is performance sensitive, modify with care!
+        //
+        // Please read PDFBOX-3854 and look at the related commits first.
+        // The current code returns TYPE_INT_RGB images which prevents slowness due to threads
+        // blocking each other when TYPE_CUSTOM images are used. 
+        // ColorConvertOp is not used here because it has a larger memory footprint and no
further
+        // performance improvement.
+        // The multiparameter setRGB() call is not used because it brings no improvement.
+
+        BufferedImage dest = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
+        int width = image.getWidth();
+        int height = image.getHeight();
+        for (int x = 0; x < width; ++x)
+        {
+            for (int y = 0; y < height; ++y)
+            {
+                dest.setRGB(x, y, image.getRGB(x, y));
+            }
+        }
+        return dest;
     }
 }



Mime
View raw message