Page 1 of 1

Question regarding Imaging.Compare API documentation

Posted: Thu May 19, 2011 2:32 pm
by bkruse
Hi,

the API documentation (Ranorex 2.3.4.9270) of Namespaces ► Ranorex ► Imaging ► Compare(Element, Bitmap, Imaging..::.FindOptions)
says (interesting parts highlighted):
public static bool Compare(
Element element,
Bitmap image,
Imaging..::.FindOptions options
)

Parameters
element (Element)
The element to make a screenshot of.
image (Bitmap)
The image to compare the screenshot with.
options (Imaging..::.FindOptions)
The options for the image comparison. The Preprocessing are applied to both images, the Clipping rectangle only to image. The Similarity defines the minimum similarity the images need to have.
Return Value
True if the similarity of the two (preprocessed) images is greater than or equal to options.Similarity.
Remarks
Falsewill be returned if the two images (after clipping image using the rectangle value of options.Clipping) do not have the same size.
Remarks
Falsewill be returned if the image and the screenshot of the element (after clipping using the rectangle value of options.Clipping) do not have the same size.
So according to the first highlighted line, the clipping is done to the image.
According to the second line, it is not distinct. I'd say it means clipping is done to the screenshot of the element.

Also, the API documentation of Namespaces ► Ranorex ► Imaging..::.FindOptions ► Clipping
says:
Remarks
The clipping rectangle will always be applied to the first argument of a method, i.e. for the FindSingle(Bitmap, Bitmap) method the value of this property is only applied to the image argument.
That would be the element in case of Imaging.Compare, which is opposite to the first highlighted line.

UseCase behind this:
I have a custom-painted toolbar. I try to verify the enabled/disabled state of a button on this toolbar.
When working with the Recorder, the Image validation offers to check if a sub-part of an image (in my case a toolbar button) is contained in the whole screenshot of an element (in my case the whole toolbar). That's what I try to get with coding. Yet to no success.

Can you pleace shed some light on how to do this?

regards, Björn

Re: Question regarding Imaging.Compare API documentation

Posted: Thu May 19, 2011 3:21 pm
by Support Team
The documentation of the Ranorex.Imaging.Compare(Element, Bitmap, Imaging.FindOptions) method is simply not correct, sorry!
As the documentation for all other Image.Compare methods and the Imaging.FindOptions.Clipping property correctly explains, the clipping is always done on the first method argument. And that is the screenshot made for the element in the Imaging.Compare(Element, Bitmap, Imaging.FindOptions) method.

We will correct the documentation for this method for the next release.
bkruse wrote:When working with the Recorder, the Image validation offers to check if a sub-part of an image (in my case a toolbar button) is contained in the whole screenshot of an element (in my case the whole toolbar). That's what I try to get with coding.
You can use the Imaging.Crop method instead to retrieve a part of the image to search for.

Regards,
Alex
Ranorex Team