/hg/gfx-test: Added four helper methods used to create test imag...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Thu Jan 10 00:54:56 PST 2013


changeset 96a64caaddec in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=96a64caaddec
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 10 09:57:59 2013 +0100

	Added four helper methods used to create test images into ImageFactory.java.


diffstat:

 ChangeLog                                   |    5 +
 src/org/gfxtest/framework/ImageFactory.java |  166 ++++++++++++++++++++++++++++
 2 files changed, 171 insertions(+), 0 deletions(-)

diffs (186 lines):

diff -r a243dee26a99 -r 96a64caaddec ChangeLog
--- a/ChangeLog	Wed Jan 09 11:10:10 2013 +0100
+++ b/ChangeLog	Thu Jan 10 09:57:59 2013 +0100
@@ -1,3 +1,8 @@
+2013-01-10  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/ImageFactory.java:
+	Added four helper methods used to create test images.
+
 2013-01-09  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/BitBltUsingBgColor.java:
diff -r a243dee26a99 -r 96a64caaddec src/org/gfxtest/framework/ImageFactory.java
--- a/src/org/gfxtest/framework/ImageFactory.java	Wed Jan 09 11:10:10 2013 +0100
+++ b/src/org/gfxtest/framework/ImageFactory.java	Thu Jan 10 09:57:59 2013 +0100
@@ -733,4 +733,170 @@
         // return buffered image containing computed color pattern
         return image;
     }
+
+    /**
+     * Create image containing red gradient.
+     * 
+     * @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 createHorizontalRedGradientImage(int width, int height, int imageType)
+    {
+        // check for proper image dimensions
+        if (width <= 0 || height <= 0)
+        {
+            return null;
+        }
+
+        // create new image
+        BufferedImage image = new BufferedImage(width, height, imageType);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // compute color for each pixel
+            int rgb = (int) Math.round(y * 256.0 / height);
+            if (rgb < 0) rgb = 0;
+            if (rgb > 255) rgb = 255;
+            int color = (0xff << 24) | (rgb << 16);
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                image.setRGB(x, y, color);
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
+
+    /**
+     * Create image containing red gradient.
+     * 
+     * @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 createVerticalRedGradientImage(int width, int height, int imageType)
+    {
+        // check for proper image dimensions
+        if (width <= 0 || height <= 0)
+        {
+            return null;
+        }
+
+        // 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
+                int rgb = (int) Math.round(x * 256.0 / width);
+                if (rgb < 0) rgb = 0;
+                if (rgb > 255) rgb = 255;
+                int color = (0xff << 24) | (rgb << 16);
+                image.setRGB(x, y, color);
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
+
+    /**
+     * Create image containing red to blue gradient.
+     * 
+     * @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 createHorizontalRedToBlueGradientImage(int width, int height, int imageType)
+    {
+        // check for proper image dimensions
+        if (width <= 0 || height <= 0)
+        {
+            return null;
+        }
+
+        // create new image
+        BufferedImage image = new BufferedImage(width, height, imageType);
+
+        // for all lines in a raster image
+        for (int y = 0; y < height; y++)
+        {
+            // compute color for each pixel
+            int rgb = (int) Math.round(y * 256.0 / height);
+            if (rgb < 0) rgb = 0;
+            if (rgb > 255) rgb = 255;
+            int invrgb = 255 - rgb;
+            int color = (0xff << 24) | (rgb << 16) | invrgb;
+            // for all columns on a line
+            for (int x = 0; x < width; x++)
+            {
+                image.setRGB(x, y, color);
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
+
+    /**
+     * Create image containing red to blue gradient.
+     * 
+     * @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 createVerticalRedToBlueGradientImage(int width, int height, int imageType)
+    {
+        // check for proper image dimensions
+        if (width <= 0 || height <= 0)
+        {
+            return null;
+        }
+
+        // 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
+                int rgb = (int) Math.round(x * 256.0 / width);
+                if (rgb < 0) rgb = 0;
+                if (rgb > 255) rgb = 255;
+                int invrgb = 255 - rgb;
+                int color = (0xff << 24) | (rgb << 16) | invrgb;
+                image.setRGB(x, y, color);
+            }
+        }
+
+        // return buffered image containing computed color pattern
+        return image;
+    }
 }



More information about the distro-pkg-dev mailing list