Bitmap Cropping

General discussion about the Phantom Automation Language and related tools.

Bitmap Cropping

Postby john on Wed Apr 06, 2011 11:04 pm

Hi All-

A new Crop() method has been added for bitmaps, allowing a loaded bitmap to be cropped to the desired size. The latest Phantom has this function, but the documentation does not list it so I wanted to add a note about it here.

The syntax is:
Code: Select all
void bitmap.Crop(int startX, startY, int Width, int Height);


Code: Select all
int startX - The zero-based starting x-pixel position, from the left hand side of the bitmap
int startY - The zero-based starting y-pixel position, from the bottom of the bitmap
int Width - The width, in pixels, of the crop
int Height - The height, in pixels, of the crop

A usage example is below:

Code: Select all
bitmap b = w.CaptureBitmap();
b.Crop(10, 10, 100, 100);

There have also been some bug fixes related to bitmap capture and searching, also available in the latest build available for download.

Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Re: Bitmap Cropping

Postby SpiritualMadMan on Sun Apr 10, 2011 1:22 pm

This is one of the best fixes John has come up with. John or I will be posting some sample code as to what can now be done with it.

I have created a "toy" that helps me utilize this fantastic, well to me it is, addition to PTD.

They can be found at: ****://****

Two things this cures for me are:

1. I am writing for older Military ATE and the VB6 Tabbed Dialog Box does not expose itself to PTD like the Page List does. This results in an inability to know which Tab is selected and the inability to select a specific Tab, except by Widow-Wide Mouse Clicks. (Not a problem with single level Tab Groupings. But with multi-level Tabs you don't know which Tabs are at which level!)

With Crop() I can bitmap capture the Window or Control and then CROP() out the Titles on the Tabs. I can then capture the the same Window or Control in real-time and then FIND() that title (assuming it is unique). Find returns the X,Y of where it found the image and then you can Mouseclick at the Window or Control Coordinates.

2. A lot of ATE uses NI Lab View Controls. We have Switch Matrixes which do not expose anything to PTD. But, with CROP() I can do the same evolution as above and then table search for matching X,Y coordinates.

Sample Code to follow.

One important note for those of you used to having the 0,0 Coordinates at the upper Left Corner... PTD places 0,0 at the LOWER left Corner... *IF* your window or control gets resized it *will* offset your Y Coordinates! This means you may have to Window.ReSize or at least check the height.)
Posts: 20
Joined: Mon Dec 06, 2010 4:02 pm

Re: Bitmap Cropping

Postby john on Thu Apr 14, 2011 12:54 am

We have since added a sample script provided by SpiritualMadMan to our Samples page on the main website. The new sample shows how to use the new crop() function and how an application can be verified/automated using bitmaps. It is the sample.

Thanks to SpiritualMadMan for providing this!

Posts: 27
Joined: Wed Apr 22, 2009 12:32 pm

Return to Phantom

Who is online

Users browsing this forum: No registered users and 1 guest