/hg/gfx-test: Added two helper methods used by BitBlt-based test...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Apr 22 01:14:12 PDT 2013


changeset ac608f047fd8 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=ac608f047fd8
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Apr 22 10:17:28 2013 +0200

	Added two helper methods used by BitBlt-based tests into
	CommonBitmapOperations and ProceduralTextureFactory.


diffstat:

 ChangeLog                                               |   6 +
 src/org/gfxtest/framework/CommonBitmapOperations.java   |  55 +++++++++++++++++
 src/org/gfxtest/framework/ProceduralTextureFactory.java |  32 +++++++++
 3 files changed, 93 insertions(+), 0 deletions(-)

diffs (116 lines):

diff -r 5501ae1df2f1 -r ac608f047fd8 ChangeLog
--- a/ChangeLog	Fri Apr 19 11:26:49 2013 +0200
+++ b/ChangeLog	Mon Apr 22 10:17:28 2013 +0200
@@ -1,3 +1,9 @@
+2013-04-22  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/CommonBitmapOperations.java:
+	* src/org/gfxtest/framework/ProceduralTextureFactory.java:
+	Added two helper methods used by BitBlt-based tests.
+
 2013-04-19  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/ProceduralTextureFactory.java:
diff -r 5501ae1df2f1 -r ac608f047fd8 src/org/gfxtest/framework/CommonBitmapOperations.java
--- a/src/org/gfxtest/framework/CommonBitmapOperations.java	Fri Apr 19 11:26:49 2013 +0200
+++ b/src/org/gfxtest/framework/CommonBitmapOperations.java	Mon Apr 22 10:17:28 2013 +0200
@@ -2049,4 +2049,59 @@
         return BitBltOperations.performBitBlt(bufferedImage, image, graphics2d, width, height) ? TestResult.PASSED : TestResult.FAILED;
     }
 
+    /**
+     * Create new buffered image containing RGB patter #1 and then perform
+     * basic BitBlt test.
+     * 
+     * @param image
+     *            image to which another image is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param imageType
+     *            type of the created image
+     */
+    public static TestResult doBitBltTestWithRGBTexture1Image(TestImage image, Graphics2D graphics2d, int imageType)
+    {
+        // create new buffered bitmap with given type
+        BufferedImage bufferedImage = ProceduralTextureFactory.createRGBTexture1(DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+
+        // basic check if buffered image was created
+        if (bufferedImage == null)
+        {
+            return TestResult.FAILED;
+        }
+        // BitBlt with custom scaling
+        return BitBltOperations.performBitBlt(bufferedImage, image, graphics2d) ? TestResult.PASSED : TestResult.FAILED;
+    }
+
+    /**
+     * Create new buffered image containing RGB patter #1 and then perform
+     * basic BitBlt test.
+     * 
+     * @param image
+     *            image to which another image is to be drawn
+     * @param graphics2d
+     *            graphics canvas
+     * @param imageType
+     *            type of the created image
+     * @param width
+     *            width of a image after BitBlt operation is performed
+     * @param height
+     *            height of a image after BitBlt operation is performed
+     */
+    public static TestResult doBitBltTestWithRGBTexture1Image(TestImage image, Graphics2D graphics2d, int imageType,
+                    int width, int height)
+    {
+        // create new buffered bitmap with given type
+        BufferedImage bufferedImage = ProceduralTextureFactory.createRGBTexture1(DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+
+        // basic check if buffered image was created
+        if (bufferedImage == null)
+        {
+            return TestResult.FAILED;
+        }
+        // BitBlt with custom scaling
+        return BitBltOperations.performBitBlt(bufferedImage, image, graphics2d, width, height) ? TestResult.PASSED : TestResult.FAILED;
+    }
+
 }
diff -r 5501ae1df2f1 -r ac608f047fd8 src/org/gfxtest/framework/ProceduralTextureFactory.java
--- a/src/org/gfxtest/framework/ProceduralTextureFactory.java	Fri Apr 19 11:26:49 2013 +0200
+++ b/src/org/gfxtest/framework/ProceduralTextureFactory.java	Mon Apr 22 10:17:28 2013 +0200
@@ -1015,4 +1015,36 @@
         return new TexturePaint(RGBTexture6Factory(image.getWidth(), image.getHeight()), anchor);
     }
 
+    /**
+     * Create new RGB pattern using given image type.
+     * 
+     * @param width
+     *            width of a texture
+     * @param height
+     *            height of a texture
+     * @param imageType
+     *            required image type
+     * @return buffered image containing texture
+     */
+    public static BufferedImage createRGBTexture1(int width, int height, int imageType)
+    {
+        // create new texture instead
+        RGBTexture1  = 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 red = colorComponentFromXOrYCoordinate(width, x);
+                int green = colorComponentFromXOrYCoordinate(height, y);
+                int blue = 0;
+                int color = makeRGBColor(red, green, blue);
+                RGBTexture1.setRGB(x, y, color);
+            }
+        }
+        return RGBTexture1;
+    }
+
 }



More information about the distro-pkg-dev mailing list