Start the snap job.
long StartSnap ();
If the function succeeds, the return value is zero.
If the function fails, the return value is nonzero.
It may return one of the following values:
Error code | Description |
---|---|
0 | Return successful |
1 | The snap process is time out. You can call function SetTimeOut to set the time out value. |
2 | The trial version is expired. You should visit http://www.acasystems.com to purchase a license, and then call SetRegInfo() before calling StartSnap() |
3 | The network or website errors. |
The function StartSnap navigates a hidden WebBrowser to open the specified URL and takes a snapshot for the web page. You must call function SetURL() to set the URL to be taken snapshot before call StartSnap.
You can call function SaveImage() to save the image to the local file after function StartSnap succeeds.
An example for VC++:
void SnapExample() { HRESULT hr; IThumbMaker * t_xpMaker = NULL; // Initializes the COM library on the current thread CoInitialize(NULL); hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_xpMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_xpMaker->SetURL( _T("http://www.acasystems.com") ); t_lRet = t_xpMaker->StartSnap(); if ( 0 == t_lRet ) { // Snap successful, call SaveImage() to save the image, and then call // WIN32 API ShellExecute() to open the image by default image viewer. t_xpMaker->SaveImage( _T("c:/acasystems.png") ); ShellExecute( NULL, _T("open"), _T("c:/acasystems.png"), NULL, NULL, SW_SHOW); } t_xpMaker->Release(); } }
An example for PHP:
<?php $t_xMaker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMakerfailed"); $t_xMaker->SetURL("http://www.acasystems.com"); if ( 0 == $t_xMaker->StartSnap() ) { // Snap successful, call SetImageFile() to save the image. echo "Take screenshot successful." ; $t_xMaker->SaveImage("c:/acasystems.png"); } ?>
Set the URL for the web page to be taken snapshot.
void SetURL( string strURL );
strURL
Enable/Disable ActiveX controls on the web page.
void SetActiveXEnabled ( bool bEnable );
bEnable
If the value is set to false, the ActiveX controls will not be executed.
For security reason, the default value is false.
Query whether ActiveX is enabled on the web page
bool GetActiveXEnabled ();
Boolean value that is true if the ActiveX control is enabled on the web page.
If the value is set to false, the ActiveX controls will not be executed.
For security reason, the default value is false.
Enable/Disable Java applets on the web page.
void SetJavaEnabled ( bool bEnable );
bEnable
If the value is set to false, the Java applets will not be executed.
For security reason, the default value is false.
Query whether Java applets is enabled on the web page.
bool GetJavaEnabled ();
Boolean value that is true if the Java applets is enabled on the web page.
If the value is set to false, the Java applets will not be executed.
For security reason, the default value is false.
Enable/Disable JavaScript on the web page.
void SetJScriptEnabled ( bool bEnable );
bEnable
If the value is set to false, the JavaScript will not be executed.
For security reason, the default value is false.
Query whether JavaScript is enabled on the web page.
bool GetJScriptEnabled ();
Boolean value that is true if the JavaScript is enabled on the web page.
If the value is set to false, the JavaScript will not be executed.
For security reason, the default value is false.
Enable/Disable image elements on the web page.
void SetImageEnabled ( bool bEnable );
bEnable
If the value is set to false, the images will not be shown.
The default value is true.
Query whether image elements is enabled on the web page.
bool GetImageEnabled ();
Boolean value that is true if the image elements is enabled on the web page.
If the value is set to false, the images will not be shown.
The default value is true.
Enable/Disable Video on the web page.
void SetVideoEnabled ( bool bEnable );
bEnable
If the value is set to false, the video on the web page will not be downloaded and played.
For security reason, the default value is false.
Query whether Video is enabled on the web page.
bool GetVideoEnabled ();
Boolean value that is true if the video is enabled on the web page.
If the value is set to false, the video on the web page will not be downloaded and played.
For security reason, the default value is false.
Set the size of the hidden web browser window.
void SetBrowserSize ( long lWidth, long lHeight );
lWidth
lHeight
The default size of the web browser window is 1024x768.
An example for VC++:
void SnapExample() { HRESULT hr; IThumbMaker * t_xpMaker = NULL; // Initializes the COM library on the current thread CoInitialize(NULL); hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_xpMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_xpMaker->SetURL( _T("http://www.acasystems.com") ); t_xpMaker->SetBrowserSize(800, 600); // Set browser size to 800x600 t_lRet = t_xpMaker->StartSnap(); if ( 0 == t_lRet ) { // Snap successful, call SetImageFile() to save the image, and then call // WIN32 API ShellExecute() to open the image by default image viewer. t_xpMaker->SaveImage( _T("c:/acasystems.png") ); ShellExecute( NULL, _T("open"), _T("c:/acasystems.png"), NULL, NULL, SW_SHOW); } t_xpMaker->Release(); } }
An example for PHP:
<?php $t_xMaker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMakerfailed"); $t_xMaker->SetURL("http://www.acasystems.com"); $t_xMaker->SetBrowserSize(800, 600); // Set browser size to 800x600 if ( 0 == $t_xMaker->StartSnap() ) { // Snap successful, call SetImageFile() to save the image. echo "Take screenshot successful." ; $t_xMaker->SaveImage("c:/acasystems.png"); echo "Take screenshot successful. "; } ?>
Get the width of the hidden web browser window.
long GetBrowserWidth();
The width of the hidden web browser window.
The default size of the web browser window is 1024x768.
Get the Height of the hidden web browser window.
long GetBrowserHeight();
The height of the hidden web browser window.
The default size of the web browser window is 1024x768.
Set the time out value in seconds for function StartSnap.
void SetTimeOut( long lTimeOut );
lTimeOut
The default timeout value is 120 seconds.
Get the timeout value in seconds for function StartSnap.
long GetTimeOut();
The timeout value in seconds.
The default timeout value is 120 seconds. If the timeout value is set to zero, no time limit is imposed.
Specifies the delay time value for StartSnap function, in milliseconds.
void SetDelayTime( long lDelayTime );
lDelayTime
The default delay time value is zero.
If you want to take snapshot from the web page that including the video(e.x. YouTube video), you should call SetDelayTime to specify a delay time for loading the video.
Get the delay time value for StartSnap function, in milliseconds.
long GetDelayTime();
The delay time in milliseconds.
The default delay time value is zero.
Save an image as the specified type.
bool SaveImage ( string strSaveFile );
strSaveFile
If the function succeeds, the return value is true.
If the function fails, the return value is false
Call this function to save the image using a specified name and type. the file name's file extension will be used to determine the image format. For example: "c:/mytest.jpg" or "c:/mytest.png".
ACA WebThumb ActiveX Control supports for following image formats:
An example for VC++:
void SnapExample() { HRESULT hr; IThumbMaker * t_xpMaker = NULL; // Initializes the COM library on the current thread CoInitialize(NULL); hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_xpMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_xpMaker->SetURL( _T("http://www.acasystems.com") ); t_lRet = t_xpMaker->StartSnap(); if ( 0 == t_lRet ) { // Snap successful, save image as .PNG format t_xpMaker->SaveImage( _T("c:/acasystems.png") ); // Snap successful, save image as .JPG format t_xpMaker->SaveImage( _T("c:/acasystems.jpg") ); } t_xpMaker->Release(); } }
An example for PHP:
<?php $t_xMaker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMakerfailed"); $t_xMaker->SetURL("http://www.acasystems.com"); if ( 0 == $t_xMaker->StartSnap() ) { // Snap successful, save image as .PNG format $t_xMaker->SaveImage("c:/acasystems.png"); // Snap successful, save image as .JPG format $t_xMaker->SaveImage("c:/acasystems.jpg"); echo "Take screenshot successful. "; } ?>
Set thumbnail image size.
void SetThumbSize ( long lWidth, long lHeight, long lRatioType );
lWidth
If lWidth and lHeight is set to zero, the image will be saved with full size.
If lWidth is set to zero and lHeight is set to nonzero, the function will auto calculate the image width.
lHeight
If lWidth and lHeight is set to zero, the image will be saved with full size.
If lHeight is set to zero and lWidth is set to nonzero, the function will auto calculate the image height.
lRatioType
If lWidth or lHeight is set to zero, this parameter will be ignored.
The default thumbnail width and height is set to zero, the image will be saved with full size.
An example for VC++:
void SnapExample() { HRESULT hr; IThumbMaker * t_xpMaker = NULL; // Initializes the COM library on the current thread CoInitialize(NULL); hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_xpMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_xpMaker->SetURL( _T("http://www.acasystems.com") ); t_lRet = t_xpMaker->StartSnap(); if ( 0 == t_lRet ) { // save image with full size t_xpMaker->SetThumbSize (0,0,0); t_xpMaker->SaveImage( _T("c:/acasystems_full.png") ); // set image size to 320x240, keep ratio by width t_xpMaker->SetThumbSize (320,240,0); t_xpMaker->SaveImage( _T("c:/acasystems_320x240.png") ); // set image width to 320, auto calculate the image height. t_xpMaker->SetThumbSize (320,0,0); t_xpMaker->SaveImage( _T("c:/acasystems_320xauto.png") ); // set image height 240, auto calculate the image width. t_xpMaker->SetThumbSize (0,240,0); t_xpMaker->SaveImage( _T("c:/acasystems_autox240.png") ); } t_xpMaker->Release(); } }
An example for PHP:
<?php $t_xMaker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMaker failed"); $t_xMaker->SetURL("http://www.acasystems.com"); if ( 0 == $t_xMaker->StartSnap() ) { // save image with full size $t_xMaker->SetThumbSize (0,0,0); $t_xMaker->SaveImage( "c:/acasystems_full.png") ; // set image size to 320x240, keep ratio by width $t_xMaker->SetThumbSize (320,240,0); $t_xMaker->SaveImage( "c:/acasystems_320x240.png"); // set image width to 320, auto calculate the image height. $t_xMaker->SetThumbSize (320,0,0); $t_xMaker->SaveImage( "c:/acasystems_320xauto.png"); // set image height 240, auto calculate the image width. $t_xMaker->SetThumbSize (0,240,0); $t_xMaker->SaveImage( "c:/acasystems_autox240.png"); echo "Take screenshot successful. "; } ?>
Get the width value of the thumbnail image.
long GetThumbWidth();
The real width of thumbnail image.
Get the height value of the thumbnail image.
long GetThumbHeight();
The real height of thumbnail image.
Get the ratio type value of the thumbnail image.
long GetThumbRatioType();
The ratio type value of the thumbnail image. 0: keep ratio by width; 1: keep ratio by height.
Set the number of bits-per-pixel in the image.
void SetBPP( long lBPP );
lBPP
The default BPP value is 32.
Get the number of bits-per-pixel in the image.
long GetBPP();
The number of bits-per-pixel in the image.
The default BPP value is 32.
Sets the coordinates of the specified clip rectangle to the image.
void SetClipRect( long lLeft, long lTop, long lWidth, long lHeight );
lLeft
lTop
lWidth
lHeight
Sets the coordinates of the specified clip rectangle to the image. You can use this function to take a snapshot of a long HTML and break it up into multiple images.
ASP Sample: see {install folder}/sample/asp/clip-part.asp.
PHP Sample: see {install folder}/sample/php/clip-part.php.
Gets the coordinates of the specified clip rectangle to the image.
void GetClipRect( long * lLeft, long * lTop, long * lWidth, long * lHeight );
lLeft
lTop
lWidth
lHeight
The default clip rectangle is (0, 0, 0, 0).
Set resolution(DPI) of the thumbnail image.
void SetDPI ( long lDPIx, long lDPIy );
lDPIx
lDPIy
The default DPI value is set to 96x96.
Get the horizontal resolution of the thumbnail image.
long GetDPIx();
the horizontal resolution of the thumbnail image, in dots-per-inch.
Get the p>resolution of the thumbnail image.
long GetDPIx();
the resolution of the thumbnail image, in dots-per-inch.
Get the HBITMAP handle of the thumbnail image.
long GetBitmapHandle();
If the function succeeds, the return value is the HBITMAP handle of the thumbnail image.
If the function failes, the return value is NULL.
Call this function after function StartSnap succeeds.
When you no longer need the bitmap, call the DeleteObject WINAPI function to delete it.
An example for VC++:
void SnapExample() { HRESULT hr; IThumbMaker * t_xpMaker = NULL; // Initializes the COM library on the current thread CoInitialize(NULL); hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_xpMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_xpMaker->SetURL( _T("http://www.acasystems.com") ); t_lRet = t_xpMaker->StartSnap(); if ( 0 == t_lRet ) { // Snap successful, call GetBitmapHandle() to get the HBITMAP handle HBITMAP t_hBMP = (HBITMAP)t_xpMaker->GetBitmapHandle(); if ( NULL != t_hBMP ) { // TODO: Add your codes here ... // .... // Delete the handle DeleteObject(t_hBMP); } } t_xpMaker->Release(); } }
Get the image memory-bytes of the thumbnail image.
byte[] GetBitmapHandle( string strImageFormat );
strImageFormat
Specifies the image format. For example: "png", "jpg", "gif".
ACA WebThumb ActiveX Control supports for following image formats:
A bytes array contains the image data.
Call this function after function StartSnap succeeds.
An example for PHP:
<?php // This sample script shows how to make a web thumbnial in the memory and output to client browser. // // Parameters: // url: The URL that you want to capture. // width: The thumbnail width // height: The thumbnail height // ratiotype: The width/height ratio type. 0: keep ratio by width; 1: keep ratio by height. // // Example: // <img src="onlinethumb.php?url=http://www.google.com"> or // <img src="onlinethumb.php?url=http://www.google.com&width=320&height=240&ratiotype=0"> // set the output header. header("Content-type: image/png"); // Create instance ACAWebThumb.ThumbMaker $t_xMaker = new COM("ACAWebThumb.ThumbMaker") or die(); // Get the parameters $t_strURL = isset($_GET["url"]) ? $_GET["url"] : "http://www.google.com"; $t_iWidth = isset($_GET["width"]) ? $_GET["width"] : 320; $t_iHeight = isset($_GET["height"]) ? $_GET["height"] : 240; $t_iRatioType = isset($_GET["ratiotype"]) ? $_GET["ratiotype"] : 0; // Set the URL and start snap $t_xMaker->SetURL($t_strURL); if ( 0 == $t_xMaker->StartSnap() ) { // snap successful, set the thumbnail size and get image bytes $t_xMaker->SetThumbSize ($t_iWidth, $t_iHeight, $t_iRatioType); $t_arrBytes = $t_xMaker->GetImageBytes ("png"); // output the image bytes to client if ( count($t_arrBytes) > 0 ) { foreach($t_arrBytes as $byte) echo chr($byte); } } ?>
Get the quality level of the JPEG image.
long GetJpegQuality();
Return the JPEG quality level. A quality level of 0 corresponds to the greatest compression(worst quality), and a quality level of 100 corresponds to the least compression(best quality).
Specify the quality level when you save a JPEG image.
void SetJpegQuality( LONG lQuality );
lQuality
The default value is set to 90.
Set a timestamp to the resulting thumbnail.
void SetTimestamp ( LONG lTimeFormat );
lTimeFormat
The default value is set to 0.
Version require: >= 3.60
Get the HTML source of the current web page.
string GetHTMLSource();
You should call this API after calling StartSnap() successfully.
Version require: >= 4.00
Write one or more HTML expressions to the current web page.
void SetHTMLSource(string strHTMLSource);
You should call this API before calling StartSnap(). The parameter of API SetURL() will be ignored once API SetHTMLSource() is called.
Version require: >= 4.10
An example for PHP:
<?php $t_xMaker = new COM('ACAWebThumb.ThumbMaker') or die("Start ACAWebThumb.ThumbMakerfailed"); $t_xMaker->SetHTMLSource("<H1>Test Title</H1> <p>This is a sample.</p>"); if ( 0 == $t_xMaker->StartSnap() ) { // Snap successful, call SetImageFile() to save the image. echo "Take screenshot successful." ; $t_xMaker->SaveImage("c:/mytest.png"); } ?>
Set the registration information to remove the trial limit.
void SetRegInfo( string strRegCode );
strRegCode
You should call this function to remove the trial limit before calling StartSnap().