FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Possible to define a Area for Func. < SaveToBmp > ?
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Possible to define a Area for Func. < SaveToBmp > ?
Posted: Sun Nov 29, 2009 07:01 PM
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 :-)
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: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Sun Nov 29, 2009 07:31 PM
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 (fw): Select all Collapse
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 );
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Tue Mar 02, 2010 06:42 PM
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
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: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Possible to define a Area for Func. < SaveToBmp > ?
Posted: Thu Mar 04, 2010 01:45 PM
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?
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Thu Mar 04, 2010 01:58 PM
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 :-)
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: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Thu Mar 04, 2010 03:41 PM
For me it is working with dialogs also. Please try this sample code.
Code (fw): Select all Collapse
#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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Thu Mar 04, 2010 03:55 PM

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 :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: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Thu Mar 04, 2010 08:39 PM

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 ?

Best Regards, Saludos



Falconi Silvio
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Fri Mar 05, 2010 12:53 PM
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 :-)
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: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Fri Mar 05, 2010 01:11 PM

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

Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: Possible to define a Area for Func. &lt; SaveToBmp &gt; ?
Posted: Sat Mar 06, 2010 08:39 AM

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

Best Regards, Saludos



Falconi Silvio

Continue the discussion