pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1826734 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
Date Wed, 14 Mar 2018 16:39:38 GMT
Author: tilman
Date: Wed Mar 14 16:39:38 2018
New Revision: 1826734

URL: http://svn.apache.org/viewvc?rev=1826734&view=rev
Log:
PDFBOX-2092: just pass the raster to a fresh TYPE_INT_RGB image, no need to copy anything

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

Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java?rev=1826734&r1=1826733&r2=1826734&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
(original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/color/PDDeviceRGB.java
Wed Mar 14 16:39:38 2018
@@ -16,11 +16,8 @@
  */
 package org.apache.pdfbox.pdmodel.graphics.color;
 
-import java.awt.Transparency;
 import java.awt.color.ColorSpace;
 import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.ComponentColorModel;
 import java.awt.image.WritableRaster;
 import java.io.IOException;
 import java.util.StringTokenizer;
@@ -116,32 +113,16 @@ public final class PDDeviceRGB extends P
     public BufferedImage toRGBImage(WritableRaster raster) throws IOException
     {
         init();
-        ColorModel colorModel = new ComponentColorModel(awtColorSpace,
-                false, false, Transparency.OPAQUE, raster.getDataBuffer().getDataType());
-
-	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.
+        // Please read PDFBOX-3854 and PDFBOX-2092 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;
+        // blocking each other when TYPE_CUSTOM images are used.
+        BufferedImage image = new BufferedImage(raster.getWidth(), raster.getHeight(), BufferedImage.TYPE_INT_RGB);
+        image.setData(raster);
+        return image;
     }
 
     private static void suggestKCMS()



Mime
View raw message