hBmp := wndBitmap( oDlg:hWnd )But, how I can write this image of hBmp into a simple variavel?
JĂșlio CĂ©sar M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
hBmp := wndBitmap( oDlg:hWnd )Hello JC,
You can use nCONVERT ( download from the Image-viewer-toppic )
You can use this tool also with command-lines from the DOS-prompt.
There is a script to save the Image of the clipboard to any Image-format.
I think Freeimage.dll doesn't support < save from clipboard >.
A easy way : Use xNVIEW and store the clipboard-image to any format
you like.
If You want to use nCONVERT, I can give You a sample, how to use it.
It is also possible to call it with WINEXEC like :
// Convert from clipboard to JPG and resize to 640x480
// -------------------------------------------------------------
cSCRIPT := "nconvert -out jpeg -resize 640 480 -clipboard"
WINEXEC("&cSCRIPT")
To use nCONVERT with WINEXEC, nCONVERT.exe must be in Your
working-directory.
I will test it and give You more detailed informations.
Regards
Uwe ![]()
cImage := someFunctionToSaveHbmp( hBmp )The function dibWrite( cBmpFile, hDib ) saves the dib handle into a file
Some like this to save into a variable?
Hello JC,
I think, something went wrong.
I answered to a question, how to save a image-capture from clipboard.
Your Question-text changed, or wrong toppic ?
Regards
Uwe ![]()
wndBitmap( oDlg:hWnd ) to variable?
But, how I can write this image of hBmp into a simple variavel?
local cImage
oDlg:SaveToBmp( "temp.txt" )
cImage = MemoRead( "temp.txt" )Antonio,
I have used this solution but in truth, I did not want to have to write a file to disk.
Just like on resolving of method ::loadFromString (), I would like something like this.
#pragma BEGINDUMP
#include <windows.h>
#include <hbapi.h>
typedef FAR * FARP;
WORD far pascal wDIBColors( LPBITMAPINFOHEADER lpBmp );
char * DibToStr( HGLOBAL hDIB, unsigned long * pulSize )
{
LPBITMAPINFO Info = ( LPBITMAPINFO ) GlobalLock( hDIB );
void * Bits = ( void * ) ( ( FARP ) Info + Info->bmiHeader.biSize +
wDIBColors( ( LPBITMAPINFOHEADER ) Info ) * sizeof( RGBQUAD ) );
unsigned long ulSize = GlobalSize( ( HGLOBAL ) Info );
BITMAPFILEHEADER bmf;
int hBmp;
char * pStr = ( char * ) hb_xgrab( sizeof( bmf ) + ulSize );
bmf.bfType = 'BM';
bmf.bfSize = sizeof( bmf ) + ulSize;
bmf.bfReserved1 = 0;
bmf.bfReserved2 = 0;
bmf.bfOffBits = sizeof( bmf ) + ( FARP ) Bits - ( FARP ) Info;
memcpy( pStr, ( const char * ) &bmf, sizeof( bmf ) );
memcpy( pStr + sizeof( bmf ), ( const char * ) Info, ulSize );
GlobalUnlock( hDIB );
* pulSize = sizeof( bmf ) + ulSize;
return pStr;
}
//---------------------------------------------------------------------------//
HB_FUNC( DIBTOSTR ) // ( hDib ) --> cString
{
unsigned long ulSize = 0;
char * pStr = DibToStr( ( HGLOBAL ) hb_parnl( 1 ), &ulSize );
hb_retclen( pStr, ulSize );
hb_xfree( ( void * ) pStr );
}
//---------------------------------------------------------------------------//
#pragma ENDDUMPAntonio,
Thank you very much!
I will try this solution and report the results!