Are you looking for a solution to convert html to image in your Visual C++ application? ACA WebThumb ActiveX is one of the best choices you can save long HTML page to image as as JPG, GIF, PNG, BMP, TIFF, WMF and EMF format with a few function calls, you can get the image bytes in memory and image bitmap Handle also. Now, you can easily add "HTML to PNG", "HTML to JPG", "Web thumbnail maker" feature in your VC++ application.
Free Trial ACA WebThumb ActiveX Now
// // Function: Convert_HTML_To_Image() // This VC++ sample shows how to convert the HTML page to image, save as PNG format, // and then call WIN32API ShellExecute() to open the image by default image viewer // void Convert_HTML_To_Image() { CoInitialize(NULL); // Initializes the COM library on the current thread HRESULT hr; IThumbMaker * t_pWebThumbMaker = NULL; hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_pWebThumbMaker ); if ( SUCCEEDED(hr) ) { t_pWebThumbMaker->SetURL("http://www.acasystems.com"); // Set URL if ( 0 == t_pWebThumbMaker->StartSnap() ) { // Save as PNG image t_pWebThumbMaker->SaveImage( _T("c:/acasystems-snapshot.png") ); // call WIN32API ShellExecute() to open the image by default image viewer. ShellExecute( NULL, _T("open"), _T("c:/acasystems-snapshot.png"), NULL, NULL, SW_SHOW); } t_pWebThumbMaker->Release(); } CoUninitialize(); }
// // Function: Convert_HTML_To_HBITMAP() // This VC++ sample shows how to convert the HTML page to image, // and then call GetBitmapHandle() to get the HBITMAP handle in memory. // void Convert_HTML_To_HBITMAP() { HRESULT hr; IThumbMaker * t_pWebThumbMaker = NULL; CoInitialize(NULL); // Initializes the COM library on the current thread hr = CoCreateInstance( __uuidof(ThumbMaker), NULL, CLSCTX_INPROC_SERVER, __uuidof(IThumbMaker), (void**)&t_pWebThumbMaker ); if ( SUCCEEDED(hr) ) { long t_lRet = 0; t_pWebThumbMaker->SetURL( _T("http://www.acasystems.com") ); t_lRet = t_pWebThumbMaker->StartSnap(); if ( 0 == t_lRet ) { // Snap successful, call GetBitmapHandle() to get the HBITMAP handle HBITMAP t_hBitmapHandle = (HBITMAP)t_pWebThumbMaker->GetBitmapHandle(); if ( NULL != t_hBitmapHandle ) { // TODO: Add your codes here ... // ... // Delete the bitmap handle DeleteObject(t_hBitmapHandle); } } t_pWebThumbMaker->Release(); } CoUninitialize(); // Don't forget close the COM library on the current thread }
Free Trial ACA WebThumb ActiveX Now