Convert a bitmap to jpeg with SilkTest Classic
CaptureBitmap() method saves a bitmap image to a file and returns the absolute or relative path of the captured bitmap. It is not possible to capture the image in a different format (Eg - JPEG).
However it is possible to convert the bitmap image to jpeg. This is useful as jpeg's normally will be smaller in memory. You can use freeware commandline utility "BMP2JPG" to convert the bitmap and call this from SilkTest using SYS_Execute().
This utility can be download from following link:- http://www.microtom.net/?p=619
The BMP2JPG command will convert a bmp to jpg. See syntax:.
BMP2JPG [Source Directory or File] [Destination Directory or File] [overwrite].
You can use this in your SilkTest script to convert your captured bitmap file to jpg and save it to the specified directory. See testcase below:-
[-] testcase ConvertToJpg ()
[ ] TestApplication.SetActive()
[ ] TestApplication.CheckBox.Select()
[ ] TestApplication.CheckBoxDialog.SetActive()
[ ] TestApplication.CheckBoxDialog.CaptureBitmap("C:\Bmptojpg\mybitmap.bmp") //capture image as bitmap
[ ] SYS_Execute("C:\Bmptojpg\ConvertToJpg.bat") //call bat file that converts to jpg
The details of the bat file (C:\Bmptojpg\ConvertToJpg.bat) referenced in the script is listed below;-
BMP2JPG "c:\Bmptojpg\mybitmap.bmp" "c:\Bmptojpg\myjpeg.jpg"