How to save the Wndcopy()'s Clipboard's output to a BMP ?
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
How to save the Wndcopy()'s Clipboard's output to a BMP ?
Hello friends,
As per the subject.
- Ramesh Babu
As per the subject.
- Ramesh Babu
Re: How to save the Wndcopy()'s Clipboard's output to a BMP
Ramesh,RAMESHBABU wrote:Hello friends,
As per the subject.
- Ramesh Babu
oWnd:SaveToBmp( "mibmp.bmp" )
William, Morales
Saludos
méxico.sureste
Saludos
méxico.sureste
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
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.
- Ramesh Babu P
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.
- Ramesh Babu P
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Ramesh,
Code: Select all
METHOD SaveToBmp( cBmpFile ) CLASS TWindow
local hBmp := WndBitmap( ::hWnd )
local hDib := DibFromBitmap( hBmp )
DibWrite( cBmpFile, hDib )
GloBalFree( hDib )
DeleteObject( hBmp )
return ( File( cBmpFile ) )
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Mr.Antonio
Thanks for your attention.
The following code is a "savedbmp.bmp" with only 14 bytes !.
As Mr.James said, I need to save the contents of clipboard to a BMP file.
I am using FWH 2.8 (Sep. build) + xHarbour 0.99.71 (Simplex)
This was working very well in our earlier versioins. But it is not working.
And I have come across several postings on our forum with the same
complaint that they are getting a saved BMP file only with 14 bytes.
Currently I have adopted a very long work around using some 3 party utilitys to achive this result.
Plase do help.
- Ramesh Babu P
Thanks for your attention.
The following code is a "savedbmp.bmp" with only 14 bytes !.
Code: Select all
#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 nil
As Mr.James said, I need to save the contents of clipboard to a BMP file.
I am using FWH 2.8 (Sep. build) + xHarbour 0.99.71 (Simplex)
This was working very well in our earlier versioins. But it is not working.
And I have come across several postings on our forum with the same
complaint that they are getting a saved BMP file only with 14 bytes.
Currently I have adopted a very long work around using some 3 party utilitys to achive this result.
Plase do help.
- Ramesh Babu P
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Ramesh,
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
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
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Mr.Antonio
As I have already pointed, the same functionality was working OK prior to
FWH 2.8 and it stopped working in 2.8 I don't know why.
Can you please check with FWH 2.8 (Sep. build) + xHarbour 0.99.71 (Simplex) and suggest me any way out ?
For your information, we have spoken several times in the forum earlier on
the same issue. And you said the same thing. I hope atleast this time so
will suggest me a way out. Because the working around way I am following presently is not giving the expected result some times and I am
facing problems.
My previous posting on the same subject for your reference:
http://fivetechsoft.com/forums/viewtop ... =save2bmp
Thanks
- Ramesh Babu P
As I have already pointed, the same functionality was working OK prior to
FWH 2.8 and it stopped working in 2.8 I don't know why.
Can you please check with FWH 2.8 (Sep. build) + xHarbour 0.99.71 (Simplex) and suggest me any way out ?
For your information, we have spoken several times in the forum earlier on
the same issue. And you said the same thing. I hope atleast this time so
will suggest me a way out. Because the working around way I am following presently is not giving the expected result some times and I am
facing problems.
My previous posting on the same subject for your reference:
http://fivetechsoft.com/forums/viewtop ... =save2bmp
Thanks
- Ramesh Babu P
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Ramesh,
Try this:
Try this:
Code: Select all
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 )
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- RAMESHBABU
- Posts: 591
- Joined: Fri Oct 21, 2005 5:54 am
- Location: Secunderabad (T.S), India
Mr.Antonio
Thank you very much for not leaving me in vain.
Please look into it and suggest me, if any thing is to be modified.
Thank you once again,
- Ramesh Babu P
FWH 2.8 (Sep Build) + xHarbour 0.99.71 (Simplex)
Thank you very much for not leaving me in vain.
Code: Select all
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 ) ) );
}
Thank you once again,
- Ramesh Babu P
FWH 2.8 (Sep Build) + xHarbour 0.99.71 (Simplex)
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact: