The Image API provides classes and interfaces to take screenshots, to
save or load images or for own image comparisons. The image API is designed so that the
different methods in general do not throw any exception. Instead, the different methods
are logging warnings.
Following is a list of the methods of the ImageWrapper
class in alphabetical order. The syntax used is a bit of a
mixture of Java and Python. Python doesn't support static
typing, but the parameters are passed on to Java, so they must be
of the correct type to avoid triggering exceptions.
If a parameter is followed by an '=' character and a value, that
value is the default and the parameter is optional.
ImageWrapper ImageWrapper(RunContext rc)
Constructor method of the ImageWrapper class.
Parameters
rc
The current run context of QF-Test.
int getMonitorCount()
Return the number of monitors.
Returns
The total number of monitors.
ImageRep grabImage(Object com, int x=None, int y=None, int width=None, int height=None)
Take screenshot of a given component. If you use the parameters
x, y, width and height, you can take a screenshot of
a specific region of the component.
Parameters
com
The QF-Test ID of the component to take a screenshot from.
x
The X coordinate of the left upper corner of the region to take the screenshot.
y
The Y coordinate of the left upper corner of the region to take the screenshot.
width
The width of the region to take the screenshot.
height
The height of the region to take the screenshot.
Returns
An ImageRep object containing the actual screenshot.
ImageRep grabScreenshot(int x=None, int y=None, int width=None, int height=None)
Take screenshot of the whole screen. If you use the parameters
x, y, width and height, you can take a screenshot of
a specific region of the screen.
Parameters
x
The X coordinate of the left upper corner of the region to take the screenshot.
y
The Y coordinate of the left upper corner of the region to take the screenshot.
width
The width of the region to take the screenshot.
height
The height of the region to take the screenshot.
Returns
An ImageRep object containing the actual screenshot.
ImageRep grabScreenshotOfAllScreens()
Creates a combined screenshot of all available screens.
Returns
An ImageRep object
ImageRep[] grabScreenshots(int monitor=None)
Take screenshots of all available screens. This method might be
useful, if you work with more than one screen.
If you want to take a screenshot of one specific screen, you can
also use this method.
Parameters
monitor
Index of the monitor to take the screenshot from. The first
monitor has 0, the second 1 and so on.
Returns
An array of ImageRep objects of all
screenshots or the specific ImageRep object, if the monitor
parameter has been used.
ImageRep loadPng(String filename)
Load an image from a given file return an ImageRep
object containing this image. The file has to contain the image
in PNG format.
Parameters
filename
The path to the file, where the image is stored.
Returns
An ImageRep object containing loaded image.
void savePng(String filename, ImageRep image)
Save the given ImageRep object to a file. The file
will be in PNG format.
Parameters
filename
The path to the file, where the image should be stored to.
image
The ImageRep object to store.
Image unwrapImage(ImageRep imageRep)
Extract the Java AWT Image from an ImageRep object.
Parameters
imageRep
The ImageRep object to extract the image from.
Returns
A Java AWT Image created from the content of the
ImageRep object, or null if imageRep
is null.
ImageRep wrapImage(Image image, String name=None)
Create an ImageRep object from a Java AWT Image.
Parameters
image
The Java AWT Image to wrap.
name
An optional name for the image.
Returns
An ImageRep object wrapping the given image, or
null if image is null.