Hello friends,
As per the subject.
- Ramesh Babu
Hello friends,
As per the subject.
RAMESHBABU wrote:Hello friends,
As per the subject.
- Ramesh Babu
Hello Mr. Wmormar
This is not that much simple. At least in FWH 2.8 xHarbour (0.99.71 Simplex) !.
Which version of FWH and xHarbour you are using and you got it working?
I have used several methods to achive this well with in FWH. But I did
not suceeed. I had to adopt a long work around to achive this.
Thanks for your response.
METHOD SaveToBmp( cBmpFile ) CLASS TWindow
local hBmp := WndBitmap( ::hWnd )
local hDib := DibFromBitmap( hBmp )
DibWrite( cBmpFile, hDib )
GloBalFree( hDib )
DeleteObject( hBmp )
return ( File( cBmpFile ) )Antonio,
Is that saving a bitmap snapshot of the window to a BMP file?
I think Ramesh wants to save a bitmap that is in the clipboard to a file. Is that right Ramesh?
James
#include "Fivewin.ch"
FUNCTION Main()
LOCAL oWnd
DEFINE WINDOW oWnd TITLE "SaveToBmp"
@ 9, 2 BUTTON "Save To Bmp" ;
SIZE 210, 30 ;
ACTION ( oWnd:SaveToBmp("SavedBmp.Bmp"), MsgInfo("Saved") )
ACTIVATE WINDOW oWnd
RETURN nilRamesh,
Your code is working fine here using FWH 7.10 and Vista Ultimate 32 bits:
Using Harbour:
10/12/2007 08:12 1,168 b32.bc
10/12/2007 08:11 0 clip.log
10/12/2007 08:12 630,074 SavedBmp.Bmp
10/12/2007 08:11 4,694 test.c
10/12/2007 08:12 1,086,976 test.exe
10/12/2007 08:12 373,443 test.map
10/12/2007 08:12 2,096 test.obj
10/12/2007 08:11 1,147 test.ppo
10/12/2007 08:11 293 test.prg
10/12/2007 08:12 458,752 test.tds
10 File(s) 2,558,643 bytes
Using xHarbour:
10/12/2007 08:16 <DIR> .
10/12/2007 08:16 <DIR> ..
10/12/2007 08:16 964 b32.bc
10/12/2007 08:16 480 clip.log
10/12/2007 08:16 630,074 SavedBmp.Bmp
10/12/2007 08:16 1,278,464 test.exe
10/12/2007 08:16 435,917 test.map
10/12/2007 08:16 10,604 test.obj
10/12/2007 08:16 1,253 test.ppo
10/12/2007 08:11 293 test.prg
10/12/2007 08:16 655,360 test.tds
9 File(s) 3,013,409 bytes
Ramesh,
> Can you please check with FWH 2.8 (Sep. build)
We can't provide tech support for 2.8 september year 2006. There have been lots of changes both in Harbour/xHarbour and FWH. Please understand it.
We can only suggest you to upgrade to FWH 7.10
oClipBoard := TClipBoard():New( CF_BITMAP )
oClipBoard:Open()
hBmp := oClipBoard:GetData() // Get handle bitmap
oClipBoard:Close()
hDib := DibFromBitmap( hBmp ) // Write from handle
If Empty( hDib )
MsgInfo("Can't make a bitmap","Error")
RETURN
EndIf
DibWrite( "BmpFile.bmp", hDib )
GlobalFree( hDib )
DeleteObject( hBmp )Mr.James
Thank you very much for your support.
Actually the DibWrite(...) function it self not functioning properly.
It is generating a BMP file with only 14 bytes !. I have tried several
ways including yours.
Still the same problem.
Thank you once again.
Ramesh,
Please copy here the source code of your FWH DibWrite(), thanks
BOOL DibWrite( LPSTR szFileName, HGLOBAL hDIB )
{
LPBITMAPINFO Info = ( LPBITMAPINFO ) GlobalLock( hDIB );
void huge * Bits = ( void huge * ) ( ( FARP ) Info + Info->bmiHeader.biSize +
wDIBColors( ( LPBITMAPINFOHEADER ) Info ) * sizeof( RGBQUAD ) );
long lSize = GlobalSize( ( HGLOBAL ) Info );
BITMAPFILEHEADER bmf;
int hBmp;
bmf.bfType = 'BM';
bmf.bfSize = sizeof( bmf ) + lSize;
bmf.bfReserved1 = 0;
bmf.bfReserved2 = 0;
bmf.bfOffBits = sizeof( bmf ) + ( FARP ) Bits - ( FARP ) Info;
#ifndef UNICODE
if( ( hBmp = _lcreat( szFileName, 0 ) ) != HFILE_ERROR )
{
_hwrite( hBmp, ( const char * ) &bmf, sizeof( bmf ) );
_hwrite( hBmp, ( const char * ) Info, lSize );
_lclose( hBmp );
GlobalUnlock( hDIB );
return TRUE;
}
#else
if( ( hBmp = hb_fsCreate( ( unsigned char * ) szFileName, 0 ) ) != ( int ) INVALID_HANDLE_VALUE )
{
hb_fsWriteLarge( hBmp, ( unsigned char * ) &bmf, sizeof( bmf ) );
hb_fsWriteLarge( hBmp, ( unsigned char * ) Info, lSize );
hb_fsClose( hBmp );
GlobalUnlock( hDIB );
return TRUE;
}
#endif
else
{
GlobalUnlock( hDIB );
return FALSE;
}
}
//---------------------------------------------------------------------------//
CLIPPER DIBWRITE( PARAMS ) // ( cFileName, hDib ) --> lSuccess
{
_retl( DibWrite( _parc( 1 ), ( HGLOBAL ) _parnl( 2 ) ) );
}It seems identical to the one in the current FWH release.
EMG
Ramesh,
Please email it to me, the entire dib.c, thanks