r9848 - helma/helma/trunk/src/helma/image

[email protected] Mon, 10 Aug 2009 16:28:10 +0200 (CEST)
Newsgroups gmane.comp.java.helma.cvs
Message-ID <20090810142810.BE3013D0E3@mia>
Author: lehni
Date: 2009-08-10 16:28:10 +0200 (Mon, 10 Aug 2009)
New Revision: 9848

Modified:
   helma/helma/trunk/src/helma/image/GIFEncoder.java
   helma/helma/trunk/src/helma/image/ImageFilterOp.java
   helma/helma/trunk/src/helma/image/ImageWrapper.java
Log:
A row of mostly cosmetic changes to imaging code.

Details at http://dev.helma.org/trac/helma/changeset/9848

Modified: helma/helma/trunk/src/helma/image/GIFEncoder.java
===================================================================
--- helma/helma/trunk/src/helma/image/GIFEncoder.java	2009-07-30 10:35:33 UTC (rev 9847)
+++ helma/helma/trunk/src/helma/image/GIFEncoder.java	2009-08-10 14:28:10 UTC (rev 9848)
@@ -17,13 +17,13 @@
 /*
  * The GIF encoding routines are based on the Acme libary
  *
- * The following addaptions and extensions were added by Juerg Lehni:
+ * The following changes and extensions were added by Juerg Lehni:
  * 
  * - encode now directly works on BufferedImage objects, the ImageEncoder
  *   and ImageConsumer oriented frameworks has been removed.
  * - Only BufferedImages with IndexColorModel are taken, so no more
  *   palette optimization with IntHashtable objects are necessary. If the
- *   BufferedImage is in wrong format, helma.image.Quantizie is used to
+ *   BufferedImage is in wrong format, helma.image.ColorQuantizer is used to
  *   convert it into a index based image.
  * - This version is much less space consuming as it only takes one sample
  *   row of the rastered image at a time into memory during compression.

Modified: helma/helma/trunk/src/helma/image/ImageFilterOp.java
===================================================================
--- helma/helma/trunk/src/helma/image/ImageFilterOp.java	2009-07-30 10:35:33 UTC (rev 9847)
+++ helma/helma/trunk/src/helma/image/ImageFilterOp.java	2009-08-10 14:28:10 UTC (rev 9848)
@@ -81,11 +81,11 @@
         }
         */
 
-        // allways work in integer mode. this is more effective, and most
+        // Always work in integer mode. this is more effective, and most
         // filters convert to integer internally anyhow
         ColorModel cm = new SimpleColorModel();
 
-        // create a BufferedImage of only 1 pixel height for fetching the rows of the image in the correct format (ARGB)
+        // Create a BufferedImage of only 1 pixel height for fetching the rows of the image in the correct format (ARGB)
         // This speeds up things by more than factor 2, compared to the standard BufferedImage.getRGB solution,
         // which is supposed to be fast too. This is probably the case because drawing to BufferedImages uses 
         // very optimized code which may even be hardware accelerated.
@@ -93,19 +93,18 @@
         Graphics2D g2d = row.createGraphics();
         int pixels[] = ((DataBufferInt)row.getRaster().getDataBuffer()).getData();
 
-        // make sure alpha values do not add up for each row:
+        // Make sure alpha values do not add up for each row:
         g2d.setComposite(AlphaComposite.Src);
-        // calculate scanline by scanline in order to safe memory.
+        // Calculate scanline by scanline in order to safe memory.
         // It also seems to run faster like that
         for (int y = 0; y < height; y++) {
             g2d.drawImage(src, null, 0, -y); 
-            // now pixels contains the rgb values of the row y!
+            // Now pixels contains the rgb values of the row y!
             // filter this row now:
             fltr.setPixels(0, y, width, 1, cm, pixels, 0, width);
         }
         g2d.dispose();
-
-        // the consumer now contains the filtered image, return it.
+        // The consumer now contains the filtered image, return it.
         return consumer.getImage();
     }
 
@@ -140,7 +139,7 @@
         }
         
         public int getRGB(int rgb) {
-            // this is the part that speeds up most.
+            // This is the part that speeds up most.
             // java.awt.image.ColorModel would return the same value, but with
             // 4 function calls and a lot of shifts and ors per color!
             return rgb;

Modified: helma/helma/trunk/src/helma/image/ImageWrapper.java
===================================================================
--- helma/helma/trunk/src/helma/image/ImageWrapper.java	2009-07-30 10:35:33 UTC (rev 9847)
+++ helma/helma/trunk/src/helma/image/ImageWrapper.java	2009-08-10 14:28:10 UTC (rev 9848)
@@ -364,7 +364,7 @@
     */
    public void trim(int x, int y, boolean trimLeft, boolean trimTop, boolean trimRight, boolean trimBottom) {
         BufferedImage bi = this.getBufferedImage();
-        int color = bi.getRGB(x, y), pixel;
+        int color = bi.getRGB(x, y);
         int left = 0, top = 0, right = width - 1, bottom = height - 1;
 
         // create a BufferedImage of only 1 pixel height for fetching the rows of the image in the correct format (ARGB)
@@ -447,7 +447,7 @@
     }
     
     /**
-     * resizes the image using the Graphics2D approach
+     * Resizes the image using the Graphics2D approach
      */
     protected void resize(int w, int h, boolean smooth) {
         BufferedImage buffered = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
@@ -473,7 +473,7 @@
     }
 
     /**
-     * Resize the image
+     * Resizes the image
      * 
      * @param w ...
      * @param h ...
@@ -483,19 +483,19 @@
             (double) w / width,
             (double) h / height
         );
-        // if the image is scaled, used the Graphcis2D method, otherwise use AWT:
+        // If the image is scaled, used the Graphcis2D method, otherwise use AWT:
         if (factor > 1f) {
-            // scale it with the Graphics2D approach for supperiour quality.
+            // Scale it with the Graphics2D approach for superior quality.
             resize(w, h, true);
         } else {
             // Area averaging has the best results for shrinking of images:
 
-            // as getScaledInstance is asynchronous, the ImageWaiter is needed here too:
+            // As getScaledInstance is asynchronous, the ImageWaiter is needed here too:
             // Image scaled = ImageWaiter.waitForImage(image.getScaledInstance(w, h, Image.SCALE_AREA_AVERAGING));
             // if (scaled == null)
             //     throw new RuntimeException("Image cannot be resized.");
             
-            // this version is up to 4 times faster than getScaledInstance:
+            // This version is up to 4 times faster than getScaledInstance:
             ImageFilterOp filter = new ImageFilterOp(new AreaAveragingScaleFilter(w, h));
             setImage(filter.filter(getBufferedImage(), null));
         }