Compares two bitmap files.
bCompare = SYS_CompareBitmap (sBitmap1, sBitmap2 [, sMaskFile])
Variable | Description |
---|---|
bCompare | Whether the bitmaps are the same. BOOLEAN. |
sBitmap1 | The name of a bitmap file to compare. STRING. |
sBitmap2 | The name of a bitmap file to compare to sBitmap1. STRING. |
sMaskFile | Optional: The name of a monochrome bitmap file that serves as a mask. STRING. |
SYS_CompareBitmap compares two bitmap files, including their color tables. The extra information saved in the file (bitmap size, location, and window) is ignored for the purposes of comparison. The function returns TRUE if the bitmaps compare equal, or FALSE if they do not.
If the two bitmaps have the same size and the same set of pixels, but the bitmaps use different color tables, Silk Test Classic prints the warning E_BITMAPS_DIFF_COLORTABLE in the results file. If the bitmaps are not exactly the same but their differences are below the allowable tolerance level, which is set with the OPT_BITMAP_PIXEL_TOLERANCE option, Silk Test Classic prints the warning E_BITMAPS_ALMOST_MATCH.
The Open Agent and the 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, ensure that the bitmaps have the same color depth.
To view, capture, and compare bitmaps, and to create monochrome mask files, use the Silk Test Bitmap Tool.
To save time, you can compare the cyclic redundancy check (CRC) values for two bitmaps using the GetBitmapCRC method and the SYS_GetBitmapCRC function, instead of comparing their bitmap images. However, if the CRC values of two bitmaps are the same, it does not guarantee that the images are the same. When the values are the same, it is very likely that the images are the same. Use the SYS_CompareBitmap function to determine if the images truly match.
SYS_CompareBitmap is executed by the agent process, not the Silk Test Classic process. To affect the host process, use the function with the hHost notation or machine handle operator. For more information about the machine handle operator and hHost, see Machine handle operator.
[ ] STRING sBaseline = "temp1.bmp" [ ] STRING sBitmap2 = "temp2.bmp" [ ] STRING sBitmap3 = "temp3.bmp" [-] RECT reCaptureRegion = {...} [ ] 1 [ ] 1 [ ] 375 [ ] 310 [ ] BOOLEAN bSame [ ] // take bitmaps; then compare them [ ] TextEditor.CaptureBitmap (sBaseline, reCaptureRegion) [ ] TextEditor.CaptureBitmap (sBitmap2) [ ] TextEditor.CaptureBitmap (sBitmap3) [ ] bSame = SYS_CompareBitmap (sBaseline, sBitmap2) [ ] Print (bSame) // prints: FALSE [ ] bSame = SYS_CompareBitmap (sBitmap2, sBitmap3) [-] Print (bSame) // prints: TRUE