/hg/gfx-test: 2012-01-19 Pavel Tisnovsky <ptisnovs at redhat.com>
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jan 19 03:50:11 PST 2012
changeset 2ca9bcc1fb0c in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=2ca9bcc1fb0c
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 19 12:52:36 2012 +0100
2012-01-19 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/ColorPalette.java:
* src/org/gfxtest/framework/ImageFactory.java: Added support
for new pattern types.
diffstat:
ChangeLog | 6 +
src/org/gfxtest/framework/ColorPalette.java | 12 +
src/org/gfxtest/framework/ImageFactory.java | 177 ++++++++++++++++++++++++++++
3 files changed, 195 insertions(+), 0 deletions(-)
diffs (255 lines):
diff -r 0f154450543f -r 2ca9bcc1fb0c ChangeLog
--- a/ChangeLog Wed Jan 18 10:59:30 2012 +0100
+++ b/ChangeLog Thu Jan 19 12:52:36 2012 +0100
@@ -1,3 +1,9 @@
+2012-01-19 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/ColorPalette.java:
+ * src/org/gfxtest/framework/ImageFactory.java:
+ Added support for new pattern types.
+
2012-01-18 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/CommonBitmapOperations.java:
diff -r 0f154450543f -r 2ca9bcc1fb0c src/org/gfxtest/framework/ColorPalette.java
--- a/src/org/gfxtest/framework/ColorPalette.java Wed Jan 18 10:59:30 2012 +0100
+++ b/src/org/gfxtest/framework/ColorPalette.java Thu Jan 19 12:52:36 2012 +0100
@@ -81,6 +81,18 @@
}
/**
+ * Return color for the specified position in a color palette.
+ *
+ * @param color
+ * color index
+ * @return selected color
+ */
+ public static int getColorAsInt(int color)
+ {
+ return ColorPalette.colors[color % colors.length].getRGB();
+ }
+
+ /**
* Returns 12-color palette.
*
* @return test 12-color palette
diff -r 0f154450543f -r 2ca9bcc1fb0c src/org/gfxtest/framework/ImageFactory.java
--- a/src/org/gfxtest/framework/ImageFactory.java Wed Jan 18 10:59:30 2012 +0100
+++ b/src/org/gfxtest/framework/ImageFactory.java Thu Jan 19 12:52:36 2012 +0100
@@ -98,9 +98,11 @@
boolean whiteField = evenColumn ^ evenRow;
// convert boolean into color code
int color = booleanToBlackOrWhiteColor(whiteField);
+ // set color for given pixel
image.setRGB(x, y, color);
}
}
+ // return buffered image containing computed color pattern
return image;
}
@@ -141,9 +143,11 @@
boolean whiteField = evenColumn ^ evenRow;
// convert boolean into color code
int color = booleanToBlackOrWhiteColor(whiteField);
+ // set color for given pixel
image.setRGB(x, y, color);
}
}
+ // return buffered image containing computed color pattern
return image;
}
@@ -181,9 +185,11 @@
boolean blackField = evenColumn || evenRow;
// convert boolean into color code
int color = booleanToBlackOrWhiteColor(!blackField);
+ // set color for given pixel
image.setRGB(x, y, color);
}
}
+ // return buffered image containing computed color pattern
return image;
}
@@ -221,9 +227,180 @@
boolean blackField = evenColumn || evenRow;
// convert boolean into color code
int color = booleanToBlackOrWhiteColor(!blackField);
+ // set color for given pixel
image.setRGB(x, y, color);
}
}
+ // return buffered image containing computed color pattern
+ return image;
+ }
+
+ /**
+ * Create image containing horizontal black and white stripes.
+ *
+ * @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 createHorizontalStripesImage(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 = (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 vertical black and white stripes.
+ *
+ * @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 createVerticalStripesImage(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 % 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
+ * 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 createHorizontalColorStripesImage(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++)
+ {
+ // compute color for each pixel
+ int color = ColorPalette.getColorAsInt(y);
+ // for all columns on a line
+ for (int x = 0; x < width; x++)
+ {
+ // set color for given pixel
+ image.setRGB(x, y, color);
+ }
+ }
+
+ // return buffered image containing computed color pattern
+ return image;
+ }
+
+ /**
+ * Create image containing vertical color stripes.
+ *
+ * @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 createVerticalColorStripesImage(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
+ int color = ColorPalette.getColorAsInt(x);
+ // set color for given pixel
+ image.setRGB(x, y, color);
+ }
+ }
+
+ // return buffered image containing computed color pattern
+ return image;
+ }
+
+ /**
+ * Create image containing diagonal black and white stripes.
+ *
+ * @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;
+ int color = booleanToBlackOrWhiteColor(colorFlag);
+ // set color for given pixel
+ image.setRGB(x, y, color);
+ }
+ }
+
+ // return buffered image containing computed color pattern
return image;
}
More information about the distro-pkg-dev
mailing list