Page 1 of 1
Possible to define a Area for Func. < SaveToBmp > ?
Posted: Sun Nov 29, 2009 7:01 pm
by ukoenig
Hello,
To save a complete Window or Dialog to a BMP, ( Screen-Capture )
SaveToBmp is used.
Is it possible , to define : TOP, LEFT, BOTTOM and RIGHT to save only a Screen-Area ?
Best Regards
Uwe

Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Sun Nov 29, 2009 7:31 pm
by Antonio Linares
Uwe,
SaveToBmp() uses the function WndBitmap() to create a bitmap using the whole area of the provided hWnd.
You could modify it this way:
Code: Select all | Expand
HB_FUNC( WNDBITMAP ) // hWnd [, nTop, nLeft, nBottom, nRight ] --> hBitmap
{
HWND hWnd = ( HWND ) hb_parnl( 1 );
HDC hDC = GetWindowDC( hWnd );
HDC hMem = CreateCompatibleDC( hDC );
RECT rct;
HBITMAP hBmp, hOldBmp;
if( hb_pcount() == 1 )
GetWindowRect( hWnd, &rct );
else
{
rct.top = hb_parnl( 2 );
rct.left = hb_parnl( 3 );
rct.bottom = hb_parnl( 4 );
rct.right = hb_parnl( 5 );
}
hBmp = CreateCompatibleBitmap( hDC, rct.right - rct.left,
rct.bottom - rct.top );
hOldBmp = ( HBITMAP ) SelectObject( hMem, hBmp );
BitBlt( hMem, 0, 0, rct.right - rct.left, rct.bottom - rct.top, hDC, rct.left, rct.top, SRCCOPY );
SelectObject( hMem, hOldBmp );
DeleteDC( hMem );
ReleaseDC( hWnd, hDC );
hb_retnl( ( LONG ) hBmp );
}
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Tue Mar 02, 2010 6:42 pm
by ukoenig
Antonio,
I would like to save a painted VTitle ( Screen-Section ) from the Dialog-Preview.
I tested something like oVTitle5:SaveToBmp( "Test.bmp" ),
but returns only a black BMP.
I think, maybe I can use Your Harbour-function, because I know Values : TOP, LEFT, BOTTOM, RIGHT
Do You have a small example, how to use it this way ?
It would be nice, the user can paint a VTitle and save it with a defined Size.
Optional :
hBmp = ResizeImg( aBmpPal[ 1 ], nWidth, nHeight )
DeleteObject( aBmpPal[ 1 ] )
or :
oBitmap:SetSize( nHORZ, nVERT )
As well I could use it for the Browser-Previews.
For the moment, I capture the Screen and cut off the no needed area.
The Screenshot explains, what I want to do

Thank You
Best Regards
Uwe
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 1:45 pm
by nageswaragunupudi
I tested something like oVTitle5:SaveToBmp( "Test.bmp" ),
but returns only a black BMP.
Probably I could not exactly understand your problem. I am able to save full title's image with oTitle:SaveToBmp( <filename> ).
For example I could save oTitle5 in \fwh\samples\testtitl.prg as:

Is this not what you wanted? What else you are looking for? Can you please explain?
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 1:58 pm
by ukoenig
Thank You for the Response,
that is exactly, what I want to do.
Inside my Application, it returns a wrong Area.
As a test, I did some changes in FWH/samples/Testtitle.prg
I moved the VTitles to a Dialog and called on Button-Action < oTitle3:SaveToBmp( "Test.bmp" ) >
the saved BMP was OK. The same, like Your Test, but from inside a Dialog.

The problem I noticed from inside my Application.
The Vtitle itself moves to different TOP / LEFT - Position,
the complete Capture-size is the Size of the VTitle.
I have to find out, where the difference comes from.

Best Regards
Uwe

Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 3:41 pm
by nageswaragunupudi
For me it is working with dialogs also. Please try this sample code.
Code: Select all | Expand
#include 'fivewin.ch'
#include 'ttitle.ch'
function main()
local oDlg, oTitle
DEFINE DIALOG oDlg SIZE 600,200 PIXEL
@ 05,05 TITLE oTitle SIZE 290,32 OF oDlg ;
SHADOW BOTTOMRIGHT SHADOWSIZE 5
@ 10,10 TITLEIMG OF oTitle BITMAP '\fwh\bitmaps\fivetech.bmp' SIZE 48,48
ACTIVATE DIALOG oDlg CENTERED ON RIGHT CLICK oTitle:SaveToBmp( 'C:\T.BMP' )
return nil
This is the saved image.

Is this not what you are looking for?
if this is working in this sample, but not from your code, I think you need to review your code again.
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 3:55 pm
by ukoenig
It seems to work.
The problem : my Application is very nested, that might be the Reason, the different Results come from.
Window => Dialog => Folder => call of another Dialog with VTitle => Capture.
My test with the changed FWH - Testtitl.prg : Window => Dialog with Vtitle => Capture works.
I will look, where the difference comes from.
Best Regards
Uwe

Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 8:39 pm
by Silvio
I think Uwe want show a bitmap into a window
then select an area of this bitmap with the mouse making a box dotted and the have the possibilty to save the area saved into a new file or insert on xbrowse field
I have the same problem only I create the bitmap from webcam :
I must save the head of a man to insert it on a badge
it ìis possible ?
Someone can make a small sample ?
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Fri Mar 05, 2010 12:53 pm
by ukoenig
Hello Silvio,
I found a Solution, works fine for me :
The user can select between 2 Styles of capture :
1. only the VTitle
2. VTitle with Background
I need the Screenshot, to show a Preview inside a xBrowse.
The Screenshot shows a Full-Screen-Capture
I select a capture. Next I open MSPaint with the captured Image.
The Option : Full Screen
oDlg:SaveToBmp( c_path + c_SET + "\P_000.BMP" )I open the Capture with MSpaint :
WAITRUN( "MsPaint.exe " + c_path + c_SET + "\P_000.BMP" )c_SET : saves the Capture on different Places ( Subdirectory /Set1 - 4 )
Now I can resize, convert to different Format, what ever I want....
For the Capture I use a given Name of P_000.bmp
Maybe it is a Solution for You as well.

Best Regards
Uwe

Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Fri Mar 05, 2010 1:11 pm
by Silvio
NO
we can create it often external application
I 'm seeinf a class Tselectarea for scan class
this use mouse and create a box ( AREA) and save only this area...
this need to us
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Sat Mar 06, 2010 8:39 am
by Silvio
Uwe I found a class called Class SeleArea for Tscan but I think we can converte for use it to select an area of bmp or jpg
Only there are some functions Region xxxx I not Know How Create they