3.0+52.10
Image API extensions

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 ImageRep class

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 subsection 52.10.2 for further information.

 
 
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.
 
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.
ReturnsTrue, 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.

ReturnsThe current ARGB data.
 
ImageComparator getComparator()

Get the current ImageComparator implementation.

ReturnsThe current ImageComparator implementation.
 
int getHeight()

Get the height.

ReturnsThe current height.
 
String getName()

Get the name.

ReturnsThe 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.
ReturnsThe pixel value.
 
byte[] getPng()

Get the RGB data. If no RGB data is set, the ARGB data will be translated into the RGB data.

ReturnsThe current RGB data.
 
int getWidth()

Get the width.

ReturnsThe 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.

Parameters
comparator The new ImageComparator implementation.
 
void setHeight(int height)

Set the height.

Parameters
height The new height.
 
void setName(String name)

Set the name.

Parameters
name The new name.
 
void setPng(byte[] png)

Set the RGB data.

Parameters
png The new RGB data.
 
void setWidth(int width)

Set the width.

Parameters
width The new width.
 
 

The ImageComparator interface

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.

 
 
boolean equals(ImageRep actual, ImageRep expected)

Return, whether the current object is equal to a given object. It uses the equals method of the current ImageComparator implementation.

Parameters
actual The actual ImageRep object.
expected The expected ImageRep object.
ReturnsTrue, if images are equal, otherwise false.