wndBitmap( oDlg:hWnd ) to variable?

wndBitmap( oDlg:hWnd ) to variable?

Postby JC » Wed Dec 03, 2008 1:13 pm

I can make a bitmap with the dialod image with this:
Code: Select all  Expand view
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Save Image from Clipboard

Postby ukoenig » Wed Dec 03, 2008 1: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:
Last edited by ukoenig on Wed Dec 03, 2008 2:10 pm, edited 1 time in total.
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby JC » Wed Dec 03, 2008 2: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:
Code: Select all  Expand view
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Wed Dec 03, 2008 2: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Save Image from Clipboard

Postby ukoenig » Wed Dec 03, 2008 2: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Postby JC » Wed Dec 03, 2008 2: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Wed Dec 03, 2008 10:47 pm

Júlio,

Code: Select all  Expand view
   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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Thu Dec 04, 2008 1: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Thu Dec 04, 2008 3:17 pm

Please try this DibToStr():
Code: Select all  Expand view
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 41314
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Thu Dec 04, 2008 5: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests