GetBitmapCRC Function

Class

AnyWin class.

Action

Returns the CRC value of a bitmap captured from the screen.

Syntax

iCRC = window.GetBitmapCRC ([Rect, sMaskFile])
Variable Description
iCRC The CRC value of the bitmap. INTEGER.
Rect Optional: The coordinates of the region to capture, relative to the window. If Rect is omitted, the entire window is captured. RECT.
sMaskFile Optional: The name of the file that contains the mask for the bitmap. STRING.

Notes

GetBitmapCRC captures the contents of the window, performs a cyclic redundancy check on the resulting bitmap, and returns the CRC value. The CRC value is a 32-bit integer that is a reduction of the bitmap, which you can use for fast comparisons. The CRC value includes all of the bytes in the image, including the color table.

You can compare the value returned by GetBitmapCRC against the CRC value for a baseline bitmap, which you can obtain with SYS_GetBitmapCRC or a prior call to GetBitmapCRC, to see if two bitmaps are identical. This method is faster than comparing two bitmap images with SYS_CompareBitmap, and less memory consuming.

You specify the coordinates to capture with the argument Rect. Rect is a record of the RECT data type.

You can generate the file containing the mask with the Silk Test Bitmap Tool, or with any standard bitmap editing tool.

The Open Agent and Classic Agent capture bitmaps in different color depths. By default, the Open Agent captures bitmaps using the current desktop settings for color depth. The Classic Agent captures bitmaps as 24-bit images. If you create a mask file for the captured bitmap using the Bitmap Tool that comes with Silk Test Classic, the mask file is saved as a 24-bit bitmap. If the bitmap mask file does not have the same color depth as the bitmap that you capture, an error occurs. To ensure that VerifyBitmap functions do not fail due to different color-depth settings between the captured image and the mask image, the bitmaps must have the same color depth.

GetBitmapCRC interprets the coordinates (0,0) as the top-left corner of the window’s frame. To capture a bitmap of a window’s client area only, specify window.ClientArea as the window to capture.

You can generate the file containing the mask with any standard bitmap editing tool.

After capturing the contents of the window, GetBitmapCRC waits the time interval specified with the OPT_BITMAP_MATCH_INTERVAL option, and then recaptures the window, comparing the result against the first capture to ensure that the image is stable. You set the number of times the comparisons are made with the OPT_BITMAP_MATCH_COUNT option. If the image is not stable after the time specified with the OPT_BITMAP_MATCH_TIMEOUT option, Silk Test Classic raises the exception E_BITMAP_NOT_STABLE.

The CRC values that GetBitmapCRC returns are not only GUI-specific, but device-specific as well. For example, the same application state displayed on VGA and Super VGA monitors will most likely result in different bitmap images, and therefore in different CRC values.

Example

Verify(SYS_GetBitmapCRC("base.bmp"), Foo.GetBitmapCRC())