commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1293786 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm: FileInfo.java PnmImageParser.java
Date Sun, 26 Feb 2012 08:52:31 GMT
Author: damjan
Date: Sun Feb 26 08:52:30 2012
New Revision: 1293786

URL: http://svn.apache.org/viewvc?rev=1293786&view=rev
Log:
Use ImageBuilder for PNM files.


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/FileInfo.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/FileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/FileInfo.java?rev=1293786&r1=1293785&r2=1293786&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/FileInfo.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/FileInfo.java
Sun Feb 26 08:52:30 2012
@@ -16,12 +16,12 @@
  */
 package org.apache.commons.sanselan.formats.pnm;
 
-import java.awt.image.BufferedImage;
 import java.awt.image.DataBuffer;
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.sanselan.ImageFormat;
+import org.apache.commons.sanselan.common.ImageBuilder;
 
 public abstract class FileInfo
 {
@@ -56,15 +56,14 @@ public abstract class FileInfo
         // do nothing by default.
     }
 
-    public void readImage(BufferedImage bi, InputStream is) throws IOException
+    public void readImage(ImageBuilder imageBuilder, InputStream is) throws IOException
     {
         // is = new BufferedInputStream(is);
         // int count = 0;
         //
         // try
         // {
-        DataBuffer buffer = bi.getRaster().getDataBuffer();
-
+        
         if (!RAWBITS)
         {
             WhiteSpaceReader wsr = new WhiteSpaceReader(is);
@@ -75,7 +74,7 @@ public abstract class FileInfo
                 {
                     int rgb = getRGB(wsr);
 
-                    buffer.setElem(y * width + x, rgb);
+                    imageBuilder.setRGB(x, y, rgb);
                     // count++;
                 }
                 newline();
@@ -88,7 +87,7 @@ public abstract class FileInfo
                 for (int x = 0; x < width; x++)
                 {
                     int rgb = getRGB(is);
-                    buffer.setElem(y * width + x, rgb);
+                    imageBuilder.setRGB(x, y, rgb);
                     // count++;
                 }
                 newline();

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java?rev=1293786&r1=1293785&r2=1293786&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/pnm/PnmImageParser.java
Sun Feb 26 08:52:30 2012
@@ -34,6 +34,7 @@ import org.apache.commons.sanselan.Image
 import org.apache.commons.sanselan.ImageReadException;
 import org.apache.commons.sanselan.ImageWriteException;
 import org.apache.commons.sanselan.common.IImageMetadata;
+import org.apache.commons.sanselan.common.ImageBuilder;
 import org.apache.commons.sanselan.common.bytesource.ByteSource;
 import org.apache.commons.sanselan.util.Debug;
 
@@ -275,12 +276,10 @@ public class PnmImageParser extends Imag
             int height = info.height;
 
             boolean hasAlpha = false;
-            BufferedImage result = getBufferedImageFactory(params)
-                    .getColorBufferedImage(width, height, hasAlpha);
+            ImageBuilder imageBuilder = new ImageBuilder(width, height, hasAlpha);
+            info.readImage(imageBuilder, is);
 
-            info.readImage(result, is);
-
-            return result;
+            return imageBuilder.getBufferedImage();
         } finally
         {
             try



Mime
View raw message