CaptureBitmap Method (TestObject)

Class

TestObject.

Action

Saves a bitmap image of this object to a file. If you do not specify an absolute file name, the bitmap is saved to the default bitmap location on the machine that runs the Agent, which is %LOCALAPPDATA%/Silk/SilkTest/capturedBitmaps. The captured bitmap's pixels are stored in 32bit RGB order; when parsing the image the 4th byte (alpha channel) of every pixel must be ignored as it is used only for padding. In .NET, the constant System.Drawing.Imaging.PixelFormat.Format32bppRgb can be used for this purpose.

After capturing the object for the first time the Agent waits the time interval specified with the OPT_BITMAP_MATCH_INTERVAL option, and then recaptures the object, comparing the result against the first capture to ensure that the image is stable.

You set the number of consecutive bitmaps that must match with the OPT_BITMAP_MATCH_COUNT option. If the image is not stable after the time specified with the OPT_BITMAP_MATCH_TIMEOUT option, an BitmapNotStableException is thrown.

Syntax

C#
result = testObject.CaptureBitmap(fileName, [region])
VB
result = testObject.CaptureBitmap(fileName, [region])
Variable Description
result The absolute file name of the captured bitmap. String.
fileName The absolute or relative file name to save the bitmap to. Append .png to the filename to save the bitmap as a PNG. String.
region Optional: The coordinates for the capture region, relative to this object. Rectangle.