/hg/gfx-test: 2012-01-27 Pavel Tisnovsky <ptisnovs at redhat.com>

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Jan 27 05:45:24 PST 2012


changeset 5d9eed71daa9 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=5d9eed71daa9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Jan 27 14:47:46 2012 +0100

	2012-01-27 Pavel Tisnovsky <ptisnovs at redhat.com>

	 * src/org/gfxtest/framework/ImageFactory.java: Added new
	raster pattern generators.


diffstat:

 ChangeLog                                   |    5 +
 src/org/gfxtest/framework/ImageFactory.java |  139 ++++++++++++++++++++++++++-
 2 files changed, 136 insertions(+), 8 deletions(-)

diffs (256 lines):

diff -r af5edcbd88f4 -r 5d9eed71daa9 ChangeLog
--- a/ChangeLog	Thu Jan 26 12:02:27 2012 +0100
+++ b/ChangeLog	Fri Jan 27 14:47:46 2012 +0100
@@ -1,3 +1,8 @@
+2012-01-27  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/ImageFactory.java:
+	Added new raster pattern generators.
+
 2012-01-26  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/CommonBitmapOperations.java:
diff -r af5edcbd88f4 -r 5d9eed71daa9 src/org/gfxtest/framework/ImageFactory.java
--- a/src/org/gfxtest/framework/ImageFactory.java	Thu Jan 26 12:02:27 2012 +0100
+++ b/src/org/gfxtest/framework/ImageFactory.java	Fri Jan 27 14:47:46 2012 +0100
@@ -45,8 +45,8 @@
 
 
 /**
- * This class contains static method used for creating various procedural images
- * which is used by (for example) BitBlt tests.
+ * This class contains static methods suitable for creating various procedural
+ * images which is used by (for example) all BitBlt tests.
  * 
  * @author Pavel Tisnovsky
  */
@@ -54,6 +54,7 @@
 {
     /**
      * Converts boolean value into an integer representing black or white color.
+     * Alpha channel is also computed correctly.
      * 
      * @param whiteColorFlag
      *            true if white color is required, false otherwise
@@ -65,7 +66,7 @@
     }
 
     /**
-     * Create image containing checker black and white pattern.
+     * Create image containing basic checker black and white pattern.
      * 
      * @param gridSize
      *            size of a grid
@@ -102,12 +103,14 @@
                 image.setRGB(x, y, color);
             }
         }
+
         // return buffered image containing computed color pattern
         return image;
     }
 
     /**
-     * Create image containing diagonal checker black and white pattern.
+     * Create image containing basic diagonal checker black and white pattern.
+     * Angle of diagonal checker pattern is set to 45 degrees.
      * 
      * @param gridSize
      *            size of a grid
@@ -147,6 +150,7 @@
                 image.setRGB(x, y, color);
             }
         }
+
         // return buffered image containing computed color pattern
         return image;
     }
@@ -189,12 +193,14 @@
                 image.setRGB(x, y, color);
             }
         }
+
         // return buffered image containing computed color pattern
         return image;
     }
 
     /**
      * Create image containing simple diagonal grid black and white pattern.
+     * Angle of diagonal grid pattern is set to 45 degrees.
      * 
      * @param gridSize
      *            size of a grid
@@ -231,6 +237,7 @@
                 image.setRGB(x, y, color);
             }
         }
+
         // return buffered image containing computed color pattern
         return image;
     }
@@ -265,6 +272,7 @@
                 image.setRGB(x, y, color);
             }
         }
+
         // return buffered image containing computed color pattern
         return image;
     }
@@ -305,6 +313,42 @@
     }
 
     /**
+     * Create image containing diagonal black and white stripes.
+     * Angle of diagonal strip pattern is set to 45 degrees.
+     * 
+     * @param width
+     *            width of a buffered image
+     * @param height
+     *            height of a buffered image
+     * @param imageType
+     *            buffered image type
+     * @return buffered image containing checker pattern
+     */
+    public static BufferedImage createDiagonalStripesImage(int width, int height, int imageType)
+    {
+        // create new image
+        BufferedImage image = new BufferedImage(width, height, imageType);
+    
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                // compute color for each pixel
+                boolean colorFlag = (x+y) % 2 == 0;
+                // convert boolean into color code
+                int color = booleanToBlackOrWhiteColor(colorFlag);
+                // set color for given pixel
+                image.setRGB(x, y, color);
+            }
+        }
+    
+        // return buffered image containing computed color pattern
+        return image;
+    }
+
+    /**
      * Create image containing horizontal color stripes.
      * 
      * @param width
@@ -371,7 +415,8 @@
     }
 
     /**
-     * Create image containing diagonal black and white stripes.
+     * Create image containing diagonal color stripes.
+     * Angle of diagonal strip pattern is set to 45 degrees.
      * 
      * @param width
      *            width of a buffered image
@@ -381,7 +426,7 @@
      *            buffered image type
      * @return buffered image containing checker pattern
      */
-    public static BufferedImage createDiagonalStripesImage(int width, int height, int imageType)
+    public static BufferedImage createDiagonalColorStripesImage(int width, int height, int imageType)
     {
         // create new image
         BufferedImage image = new BufferedImage(width, height, imageType);
@@ -393,10 +438,10 @@
             for (int x = 0; x < width; x++)
             {
                 // compute color for each pixel
-                boolean colorFlag = (x+y) % 2 == 0;
-                int color = booleanToBlackOrWhiteColor(colorFlag);
+                int color = ColorPalette.getColorAsInt(x + y);
                 // set color for given pixel
                 image.setRGB(x, y, color);
+                // compute color for each pixel
             }
         }
 
@@ -404,4 +449,82 @@
         return image;
     }
 
+    /**
+     * Create image containing black and white dots pattern.
+     * 
+     * @param width
+     *            width of a buffered image
+     * @param height
+     *            height of a buffered image
+     * @param imageType
+     *            buffered image type
+     * @return buffered image containing checker pattern
+     */
+    public static BufferedImage createBWDotsPatternImage(int width, int height, int imageType)
+    {
+        // create new image
+        BufferedImage image = new BufferedImage(width, height, imageType);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                boolean colorFlag = (x % 2) == 0 || (y % 2) == 0;
+                // convert boolean into color code
+                int color = booleanToBlackOrWhiteColor(colorFlag);
+                // set color for given pixel
+                image.setRGB(x, y, color);
+                // compute color for each pixel
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
+
+    /**
+     * Create image containing color dots pattern.
+     * 
+     * @param width
+     *            width of a buffered image
+     * @param height
+     *            height of a buffered image
+     * @param imageType
+     *            buffered image type
+     * @return buffered image containing checker pattern
+     */
+    public static BufferedImage createColorDotsPatternImage(int width, int height, int imageType)
+    {
+        // create new image
+        BufferedImage image = new BufferedImage(width, height, imageType);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                int color;
+                // set color to white on even row and column 
+                if (x % 2 == 0 || y % 2 == 0)
+                {
+                    color = -1;
+                }
+                else
+                {
+                    int red = x % 4 == 1 ? 0x00 : 0xff;
+                    int green = y % 4 == 1 ? 0x00 : 0xff;
+                    int blue = 0;
+                    color = (0xff << 24) | (red << 16) | (green << 8) | blue;
+                }
+                image.setRGB(x, y, color);
+                // compute color for each pixel
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
 }



More information about the distro-pkg-dev mailing list