You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by je...@apache.org on 2008/04/13 09:33:53 UTC

svn commit: r647536 - /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java

Author: jeremias
Date: Sun Apr 13 00:33:52 2008
New Revision: 647536

URL: http://svn.apache.org/viewvc?rev=647536&view=rev
Log:
Performance improvement for fallback RGB encoding by reducing the number of IO calls. The buffering of the stream is not enough in this case.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java?rev=647536&r1=647535&r2=647536&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/ImageEncodingHelper.java Sun Apr 13 00:33:52 2008
@@ -139,16 +139,16 @@
         ColorModel colorModel = image.getColorModel();
         int w = image.getWidth();
         int h = image.getHeight();
+        byte[] buf = new byte[w * 3];
         for (int y = 0; y < h; y++) {
+            int idx = -1;
             for (int x = 0; x < w; x++) {
                 int rgb = colorModel.getRGB(raster.getDataElements(x, y, data));
-                int r = (rgb >> 16) & 0xFF;
-                int g = (rgb >> 8) & 0xFF;
-                int b = (rgb) & 0xFF;
-                out.write(r);
-                out.write(g);
-                out.write(b);
+                buf[++idx] = (byte)(rgb >> 16);
+                buf[++idx] = (byte)(rgb >> 8);
+                buf[++idx] = (byte)(rgb);
             }
+            out.write(buf);
         }
     }
     



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org