Possible to define a Area for Func. < SaveToBmp > ?

Possible to define a Area for Func. < SaveToBmp > ?

Postby ukoenig » Sun Nov 29, 2009 7: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 :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

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby Antonio Linares » Sun Nov 29, 2009 7: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: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby ukoenig » Tue Mar 02, 2010 6: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

Image

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

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby nageswaragunupudi » Thu Mar 04, 2010 1: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:
Image

Is this not what you wanted? What else you are looking for? Can you please explain?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby ukoenig » Thu Mar 04, 2010 1: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.

Image

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.

Image

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

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby nageswaragunupudi » Thu Mar 04, 2010 3:41 pm

For me it is working with dialogs also. Please try this sample code.
Code: Select all  Expand view
#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.
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
User avatar
nageswaragunupudi
 
Posts: 10627
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby ukoenig » Thu Mar 04, 2010 3: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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby Silvio » Thu Mar 04, 2010 8: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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby ukoenig » 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.

Image

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

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby Silvio » Fri Mar 05, 2010 1: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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Possible to define a Area for Func. < SaveToBmp > ?

Postby Silvio » Sat Mar 06, 2010 8: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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken and 100 guests