The Image API of QF-Test makes use of a technology independent
class for image representation ImageRep and it
offers an interface to implement an own image compare algorithm.
The class
de.qfs.apps.qftest.shared.extensions.image.ImageRep is
the wrapper class for technology independent images.
The class holds the image representation either as ARGB data,
which is an int array or as RGB data, which is a byte array.
Besides the image data, you can also specify a name, the width
and the height for the ImageRep object.
The ImageRep class also contains an equals method for
comparisons. If you want to implement your own image comparison algorithm, you
have to implement your own ImageComparator. This implementation
has to be registered at the ImageRep object. See "The ImageComparator interface" for further information.
10.0+
Image comparison can also be performed using a
Check image. To do this, you need to store the ImageRep object as a variable,
which can then be used as an image variable in the Check image. For more
information, see Check image.
ImageRep ImageRep()
Constructor for the ImageRep class.
ImageRep ImageRep(String name, byte[] rgb, boolean png, int width, int height)
Constructor method for the ImageRep class.
Parameters
name
The name of the ImageRep object.
rgb
A byte array containing RGB data of the image.
png
Whether the image is already png encoded.
width
The width of the image.
height
The height of the image.
ImageRep ImageRep(String name, int[] argb, boolean png, int width, int height)
Constructor method for the ImageRep class.
Parameters
name
The name of the ImageRep object.
argb
An int array containing the ARGB data of the image.
png
Whether the image is already png encoded.
width
The width of the image.
height
The height of the image.
void crop(int x, int y, int width, int height)
Crop the image to a specified sub-region.
Parameters
x
The X coordinate of the left upper corner of the sub-region.
y
The Y coordinate of the left upper corner of the sub-region.
width
The width of the sub-region.
height
The height of the sub-region.
ImageRepDrawer draw()
Creates an ImageRepDrawer object for this image. This image allows drawing lines, rectangles and further figures on the image.
ImageRepDrawer draw(Object obj)
Creates an ImageRepDrawer object for this image.
Parameters
obj
A lambda object. The lambda object gets a java.awt.Graphics2D object as input which it can use to draw on the image.
boolean equals(ImageRep compare)
Return, whether the current object is equal to a given
object. It uses the equals method of the current
ImageComparator implementation.
Parameters
compare
The ImageRep object to compare with.
Returns
True, if images are equal, otherwise false.
int[] getARGB()
Get the ARGB data. If no ARGB data is set, the RGB data
will be translated into the ARGB data.
Returns
The current ARGB data.
ImageComparator getComparator()
Get the current ImageComparator implementation.
Returns
The current ImageComparator implementation.
int getHeight()
Get the height.
Returns
The current height.
String getName()
Get the name.
Returns
The current name.
int getPixel(int x, int y)
Get an ARGB pixel value.
Parameters
x
The X coordinate of the pixel.
y
The Y coordinate of the pixel.
Returns
The pixel value.
byte[] getPng()
Get the RGB data. If no RGB data is set, the ARGB data
will be translated into the RGB data.
Returns
The current RGB data.
int getWidth()
Get the width.
Returns
The current width.
void setARGB(int[] argb)
Set the ARGB data.
Parameters
argb
The new ARGB data.
void setComparator(ImageComparator comparator)
Set ImageComparator implementation, which will be
used for comparing images.
The interface
de.qfs.apps.qftest.shared.extensions.image.ImageComparator
has to be implemented, if you want to implement your own image comparison
algorithm.
The implementation has then to be registered at the used ImageRep
objects using the setComparator method.
The class de.qfs.apps.qftest.shared.extensions.image.ImageRepDrawer
provides methods to draw on an ImageRep object.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2, int arrowStretch)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
arrowStretch
The size of the arrow head.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2, int arrowStretch, int strokeSize)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
arrowStretch
The size of the arrow head.
strokeSize
The size of the stroke.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2, int arrowStretch, int strokeSize, Color strokeColor)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
arrowStretch
The size of the arrow head.
strokeSize
The size of the stroke.
strokeColor
The stroke color.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2, int arrowStretch, int strokeSize, int r, int g, int b)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
arrowStretch
The size of the arrow head.
strokeSize
The size of the stroke.
r
The red part of the stroke color.
g
The green part of the stroke color.
b
The blue part of the stroke color.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer arrow(int x1, int y1, int x2, int y2, int arrowStretch, int strokeSize, int r, int g, int b, int a)
Draws an arrow.
Parameters
x1
The x-part of the first coordinate of the arrow.
y1
The y-part of the first coordinate of the arrow.
x2
The x-part of the second coordinate of the arrow.
y2
The y-part of the second coordinate of the arrow.
arrowStretch
The size of the arrow head.
strokeSize
The size of the stroke.
r
The red part of the stroke color.
g
The green part of the stroke color.
b
The blue part of the stroke color.
a
The alpha part of the stroke color.
Returns
The ImageRepDrawer object for method concatination.
BufferedImage asBufferedImage()
Converts this image to a BufferedImage.
Returns
This image as BufferedImage.
ImageRepDrawer circle(int x, int y, int r)
Draws a circle.
Parameters
x
The x-coordinate of the center of the circle.
y
The y-coordinate of the center of the circle.
r
The radius of the circle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer circle(int x, int y, int r, Color color)
Draws a circle.
Parameters
x
The x-coordinate of the center of the circle.
y
The y-coordinate of the center of the circle.
r
The radius of the circle.
color
The color of the circle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer cross(int x, int y)
Draws a cross.
Parameters
x
The x-coordinate of the cross to draw.
y
The y-coordinate of the cross to draw.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer cross(int x, int y, int size)
Draws a cross.
Parameters
x
The x-coordinate of the cross to draw.
y
The y-coordinate of the cross to draw.
size
The size of the cross to draw.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer draw(Object drawFunction)
Draws on an ImageRep object.
Parameters
drawFunction
A lambda object. The lambda object takes a java.awt.Graphics2D object as input which can be used to draw onto the image.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer erase(int x, int y, int w, int h)
"Erases" a particular area in the image.
Parameters
x
The x-coordinate of the area that should get erased.
y
The y-coordinate of the area that should get erased.
w
The width of the area that should get erased.
h
The height of the area that should get erased.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer fillRectangle(int x, int y, int w, int h)
Draws a filled rectangle.
Parameters
x
The x-coordinate of the rectangle to draw.
y
The y-coordinate of the rectangle to draw.
w
The width of the rectangle to draw.
h
The height of the rectangle to draw.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer fillRectangle(int x, int y, int w, int h, Color color)
Draws a filled rectangle.
Parameters
x
The x-coordinate of the rectangle to draw.
y
The y-coordinate of the rectangle to draw.
w
The width of the rectangle to draw.
h
The height of the rectangle to draw.
color
The color to use to fill the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer image(ImageRep imgToDraw, int x, int y)
Draws an image onto the already existing image.
Parameters
imgToDraw
The image to draw.
x
The x-coordinate where the image should get drawn.
y
The y-coordinate where the image should get drawn.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer image(Image img, int x, int y)
Draws an image onto the already existing image.
Parameters
img
The image to draw.
x
The x-coordinate where the image should get drawn.
y
The y-coordinate where the image should get drawn.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, Color strokeColor)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
strokeColor
The color that should get used for stroke drawing.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, int strokeSize)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
strokeSize
The stroke thickness.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, int strokeSize, Color strokeColor)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
strokeSize
The line thickness of the line to draw.
strokeColor
The color to use for line drawing.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, int r, int g, int b)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
r
The red value of the color that should get used for stroke drawing.
g
The green value of the color that should get used for stroke drawing.
b
The blue value of the color that should get used for stroke drawing.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, int r, int g, int b, int a)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
r
The red value of the color that should get used for stroke drawing.
g
The green value of the color that should get used for stroke drawing.
b
The blue value of the color that should get used for stroke drawing.
a
The alpha value of the color that should get used for stroke drawing.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer line(int x1, int y1, int x2, int y2, int strokeSize, int r, int g, int b, int a)
Draws a line.
Parameters
x1
The x-part of the first coordinate of the line to draw.
y1
The y-part of the first coordinate of the line to draw.
x2
The x-part of the second coordinate of the line to draw.
y2
The y-part of the second coordinate of the line to draw.
strokeSize
The line thickness of the line to draw.
r
The red value of the color to use for line drawing.
g
The green value of the color to use for line drawing.
b
The blue value of the color to use for line drawing.
a
The alpha value of the color to use for line drawing.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer pixel(int x, int y)
Colors a particular pixel on the image by using the color previously set via setStrokeColor.
In case no color was set previously, the color black will be used.
Parameters
x
The x-coordinate of the pixel that should get colored.
y
The y-coordinate of the pixel that should get colored.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer pixel(int x, int y, java.awt.Color color)
Colors a particular pixel on the image.
Parameters
x
The x-coordinate of the pixel that should get colored.
y
The y-coordinate of the pixel that should get colored.
c
The color object that should get used to color that particular pixel.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer pixel(int x, int y, int r, int g, int b)
Colors a particular pixel on the image.
Parameters
x
The x-coordinate of the pixel that should get colored.
y
The y-coordinate of the pixel that should get colored.
r
The red value of the color that should get used to color a particular pixel.
g
The green value of the color that should get used to color a particular pixel.
b
The blue value of the color that should get used to color a particular pixel.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer pixel(int x, int y, int r, int g, int b, int a)
Colors a particular pixel on the image.
Parameters
x
The x-coordinate of the pixel that should get colored.
y
The y-coordinate of the pixel that should get colored.
r
The red value of the color that should get used to color a particular pixel.
g
The green value of the color that should get used to color a particular pixel.
b
The blue value of the color that should get used to color a particular pixel.
a
The alpha value of the color that should get used to color a particular pixel.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, Color strokeColor)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeColor
The color to use for the rectangle strokes.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, Color strokeColor, Color fillColor)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeColor
The color to use for the rectangle strokes.
fillColor
The color to use to fill the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, int strokeCap, Color strokeColor)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeCap
The stroke caps to use.
strokeColor
The color to use for the rectangle strokes.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, int strokeCap, Color strokeColor, Color fillColor)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeCap
The stroke cap to use for rectangle drawing.
strokeColor
The stroke color to use for rectangle drawing.
fillColor
The color to use to fill the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, int strokeCap, int rstroke, int gstroke, int bstroke, int rfill, int gfill, int bfill)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeCap
The stroke cap to use for rectangle drawing.
rstroke
The red value of the color to use for the rectangle strokes.
gstroke
The green value of the color to use for the rectangle strokes.
bstroke
The blue value of the color to use for the rectangle strokes.
rfill
The red value of the color to use to fill the rectangle.
gfill
The green value of the color to use to fill the rectangle.
bfill
The blue value of the color to use to fill the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer rectangle(int x, int y, int w, int h, int b, int strokeCap, int rstroke, int gstroke, int bstroke, int astroke, int rfill, int gfill, int bfill, int afill)
Draws a rectangle.
Parameters
x
The x-coordinate where the rectangle should get drawn.
y
The y-coordinate where the rectangle should get drawn.
w
The width of the rectangle that should get drawn.
h
The height of the rectangle that should get drawn.
b
The width of the stroke of the rectangle.
strokeCap
The stroke cap to use for rectangle drawing.
rstroke
The red value of the color to use for the rectangle strokes.
gstroke
The green value of the color to use for the rectangle strokes.
bstroke
The blue value of the color to use for the rectangle strokes.
astroke
The alpha value of the color to use for the rectangle strokes.
rfill
The red value of the color to use to fill the rectangle.
gfill
The green value of the color to use to fill the rectangle.
bfill
The blue value of the color to use to fill the rectangle.
afill
The alpha value of the color to use to fill the rectangle.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFillColor(java.awt.Color color)
Sets the default fill color.
Parameters
color
The new fill color.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFillColor(int r, int g, int b)
Sets the default fill color.
Parameters
r
The red component of the fill color.
g
The green component of the fill color.
b
The blue component of the fill color.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFillColor(int r, int g, int b, int a)
Sets the default fill color.
Parameters
r
The red component of the fill color.
g
The green component of the fill color.
b
The blue component of the fill color.
a
The alpha component of the fill color.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFont(java.awt.Font font)
Sets the default font.
Parameters
font
The default font to use.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFont(String fontName)
Sets the default font.
Parameters
fontName
Der Name of the default font to use.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFont(String fontName, int size)
Sets the default font.
Parameters
fontName
The name of the default font to use.
size
The size of the default font to use.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setFont(String fontName, int size, int style)
Sets the default font.
Parameters
fontName
The name of the default font to use.
size
The size of the default font to use.
style
The style of the default font to use.
Returns
The ImageRepDrawer object for method concatination.
ImageRepDrawer setStrokeCap(int cap)
Set the stroke caps.
Parameters
cap
Can either be ImageRepDrawer.CAPS_SQUARED for strokes with squared caps or ImageRepDrawer.CAPS_ROUND for strokes with round caps.
Returns
The ImageRepDrawer object for method concatination.
Constructor for the
ImageRepclass.