FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour wndBitmap( oDlg:hWnd ) to variable?
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Wed Dec 03, 2008 01:13 PM
I can make a bitmap with the dialod image with this:
hBmp := wndBitmap( oDlg:hWnd )


But, how I can write this image of hBmp into a simple variavel?
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Save Image from Clipboard
Posted: Wed Dec 03, 2008 01:52 PM

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 :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Wed Dec 03, 2008 02:01 PM
Uwe,

Thanks but, I want another thing.

I want to save a handle hBmp to a variable of fivewin... something like this code:
cImage := someFunctionToSaveHbmp( hBmp )

And with this way to do, I will record this variable into a database or another place.
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Wed Dec 03, 2008 02:05 PM

The function dibWrite( cBmpFile, hDib ) saves the dib handle into a file

Some like this to save into a variable?

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Save Image from Clipboard
Posted: Wed Dec 03, 2008 02:21 PM

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 :lol:

Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Wed Dec 03, 2008 02:27 PM
Uwe,

I think not!
wndBitmap( oDlg:hWnd ) to variable?

But, how I can write this image of hBmp into a simple variavel?

Into a simple variable of fivewin! Internally!
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Wed Dec 03, 2008 10:47 PM
JĂșlio,

   local cImage

   oDlg:SaveToBmp( "temp.txt" )

   cImage = MemoRead( "temp.txt" )

You can use "temp.txt" or "temp.bmp". It doesn't matter
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Thu Dec 04, 2008 01:03 PM

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.

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Thu Dec 04, 2008 03:17 PM
Please try this DibToStr():
#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 ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
wndBitmap( oDlg:hWnd ) to variable?
Posted: Thu Dec 04, 2008 05:21 PM

Antonio,

Thank you very much!
I will try this solution and report the results!

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9

Continue the discussion