Validate.CompareImage cropped?

Ask general questions here.
MJesper
Posts: 38
Joined: Fri Dec 28, 2018 2:16 pm

Validate.CompareImage cropped?

Post by MJesper » Tue Feb 26, 2019 10:02 am

Hi, I'm trying to validate an Element with an existing screenshot which is cropped. This results in that I have to crop the result image Validate.CompareImage takes. Currently I take a temporary snapshot and compare with that and then delete it, but I want to use Validate.CompareImage so it gets into the Report log. Got any ideas? Thanks.

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Validate.CompareImage cropped?

Post by Stub » Wed Feb 27, 2019 9:20 am

I don't really understand quite what you're asking here. Are you trying to log the uncropped image? You can use Report.LogData() to log any image you like:

Code: Select all

Report.LogData(ReportLevel.Info, "Image", bitmap);

User avatar
Stub
Posts: 515
Joined: Fri Jul 15, 2016 1:35 pm

Re: Validate.CompareImage cropped?

Post by Stub » Wed Feb 27, 2019 9:23 am

You can also specify the crop rect in the FindOptions:

Code: Select all

Rectangle clipping = new Rectangle(0, 0, width, height);
Ranorex.Imaging.FindOptions find_options = new Imaging.FindOptions(clipping);
Ranorex.Validate.CompareImage(some_repo_item, expected_bitmap_image, find_options);

MJesper
Posts: 38
Joined: Fri Dec 28, 2018 2:16 pm

Re: Validate.CompareImage cropped?

Post by MJesper » Wed Feb 27, 2019 10:59 am

Thanks, didn't know about the FindOptions!