commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1293771 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp: BmpImageParser.java pixelparsers/PixelParser.java pixelparsers/PixelParserRle.java pixelparsers/PixelParserSimple.java
Date Sun, 26 Feb 2012 08:23:50 GMT
Author: damjan
Date: Sun Feb 26 08:23:50 2012
New Revision: 1293771

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


Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserRle.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserSimple.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java?rev=1293771&r1=1293770&r2=1293771&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/BmpImageParser.java
Sun Feb 26 08:23:50 2012
@@ -37,6 +37,7 @@ import org.apache.commons.sanselan.Image
 import org.apache.commons.sanselan.ImageWriteException;
 import org.apache.commons.sanselan.common.BinaryOutputStream;
 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.formats.bmp.pixelparsers.PixelParser;
 import org.apache.commons.sanselan.formats.bmp.pixelparsers.PixelParserBitFields;
@@ -713,9 +714,6 @@ public class BmpImageParser extends Imag
         int width = bhi.width;
         int height = bhi.height;
 
-        BufferedImage result = getBufferedImageFactory(params)
-                .getColorBufferedImage(width, height, true);
-
         if (verbose)
         {
             System.out.println("width: " + width);
@@ -725,10 +723,10 @@ public class BmpImageParser extends Imag
         }
 
         PixelParser pixelParser = ic.pixelParser;
+        ImageBuilder imageBuilder = new ImageBuilder(width, height, true);
+        pixelParser.processImage(imageBuilder);
 
-        pixelParser.processImage(result);
-
-        return result;
+        return imageBuilder.getBufferedImage();
 
     }
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParser.java?rev=1293771&r1=1293770&r2=1293771&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParser.java
Sun Feb 26 08:23:50 2012
@@ -16,12 +16,12 @@
  */
 package org.apache.commons.sanselan.formats.bmp.pixelparsers;
 
-import java.awt.image.BufferedImage;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
 import org.apache.commons.sanselan.ImageReadException;
 import org.apache.commons.sanselan.common.BinaryFileParser;
+import org.apache.commons.sanselan.common.ImageBuilder;
 import org.apache.commons.sanselan.formats.bmp.BmpHeaderInfo;
 
 public abstract class PixelParser
@@ -43,7 +43,7 @@ public abstract class PixelParser
         is = new ByteArrayInputStream(ImageData);
     }
 
-    public abstract void processImage(BufferedImage bi)
+    public abstract void processImage(ImageBuilder imageBuilder)
             throws ImageReadException, IOException;
 
     protected int getColorTableRGB(int index)

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserRle.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserRle.java?rev=1293771&r1=1293770&r2=1293771&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserRle.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserRle.java
Sun Feb 26 08:23:50 2012
@@ -21,6 +21,7 @@ import java.awt.image.DataBuffer;
 import java.io.IOException;
 
 import org.apache.commons.sanselan.ImageReadException;
+import org.apache.commons.sanselan.common.ImageBuilder;
 import org.apache.commons.sanselan.formats.bmp.BmpHeaderInfo;
 
 public class PixelParserRle extends PixelParser
@@ -70,7 +71,7 @@ public class PixelParserRle extends Pixe
     }
 
     private int processByteOfData(int rgbs[], int repeat, int x, int y,
-            int width, int height, DataBuffer db, BufferedImage bi)
+            int width, int height, ImageBuilder imageBuilder)
     {
         //                int rbg
         int pixels_written = 0;
@@ -83,7 +84,7 @@ public class PixelParserRle extends Pixe
                 //                    rgb = getNextRGB();
                 int rgb = rgbs[i % rgbs.length];
                 //                                bi.setRGB(x, y, rgb);
-                db.setElem(y * bhi.width + x, rgb);
+                imageBuilder.setRGB(x, y, rgb);
                 //                                bi.setRGB(x, y, 0xff00ff00);
             }
             else
@@ -98,11 +99,9 @@ public class PixelParserRle extends Pixe
         return pixels_written;
     }
 
-    public void processImage(BufferedImage bi) throws ImageReadException,
+    public void processImage(ImageBuilder imageBuilder) throws ImageReadException,
             IOException
     {
-        DataBuffer db = bi.getRaster().getDataBuffer();
-
         int count = 0;
         int width = bhi.width;
         int height = bhi.height;
@@ -183,7 +182,7 @@ public class PixelParserRle extends Pixe
                             //                                    + SamplesPerByte);
                             //                            System.out.println("towrite: "
+ towrite);
                             int written = processByteOfData(samples, towrite,
-                                    x, y, width, height, db, bi);
+                                    x, y, width, height, imageBuilder);
                             //                            System.out.println("written: "
+ written);
                             //                            System.out.println("");
                             x += written;
@@ -198,7 +197,7 @@ public class PixelParserRle extends Pixe
             {
                 int rgbs[] = convertDataToSamples(b);
 
-                x += processByteOfData(rgbs, a, x, y, width, height, db, bi);
+                x += processByteOfData(rgbs, a, x, y, width, height, imageBuilder);
                 //                    x += processByteOfData(b, a, x, y, width, height, bi);
 
             }

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserSimple.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserSimple.java?rev=1293771&r1=1293770&r2=1293771&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserSimple.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/bmp/pixelparsers/PixelParserSimple.java
Sun Feb 26 08:23:50 2012
@@ -16,10 +16,10 @@
  */
 package org.apache.commons.sanselan.formats.bmp.pixelparsers;
 
-import java.awt.image.BufferedImage;
 import java.io.IOException;
 
 import org.apache.commons.sanselan.ImageReadException;
+import org.apache.commons.sanselan.common.ImageBuilder;
 import org.apache.commons.sanselan.formats.bmp.BmpHeaderInfo;
 
 public abstract class PixelParserSimple extends PixelParser
@@ -34,7 +34,7 @@ public abstract class PixelParserSimple 
 
     public abstract void newline() throws ImageReadException, IOException;
 
-    public void processImage(BufferedImage bi) throws ImageReadException,
+    public void processImage(ImageBuilder imageBuilder) throws ImageReadException,
             IOException
     {
 //        DataBuffer db = bi.getRaster().getDataBuffer();
@@ -45,7 +45,7 @@ public abstract class PixelParserSimple 
             {
                 int rgb = getNextRGB();
 
-                bi.setRGB(x, y, rgb);
+                imageBuilder.setRGB(x, y, rgb);
 //                db.setElem(y * bhi.width + x, rgb);
             }
             newline();



Mime
View raw message