Print and save an Image

Print and save an Image

Postby Silvio.Falconi » Sat Mar 27, 2021 5:44 pm

I have an Image create wih FW_DrawImage()
How I can save and print this image ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: Print and save an Image

Postby nageswaragunupudi » Sun Mar 28, 2021 4:16 am

FW_DrawImage() does not create an image. It only displays/prints an image on the screen or printer.
Regards

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

Re: Print and save an Image

Postby Silvio.Falconi » Sun Mar 28, 2021 11:21 am

thanks resolved
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7048
Joined: Thu Oct 18, 2012 7:17 pm

Re: Print and save an Image

Postby Otto » Sun Mar 28, 2021 1:02 pm

Silvio,
Would you mind posting how?
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6322
Joined: Fri Oct 07, 2005 7:07 pm

Re: Print and save an Image

Postby AntoninoP » Sun Mar 28, 2021 1:31 pm

Otto wrote:Silvio,
Would you mind posting how?
Best regards,
Otto

I helped Silvio, we used a modified version of TWindow:SaveToBmp( cBmpFile ), SaveToBitmap uses WndBitmap, I modified it to takes a region of window:

Code: Select all  Expand view
//---------------------------------------------------------------------------//
// copied from fwh32\source\winapi\wndprint.c
HB_FUNC( WNDBITMAPRECT )  //  hWnd, aRect --> hBitmap
{
    HWND hWnd     = ( HWND ) fw_parH( 1 );
    HDC  hDC      = GetWindowDC( hWnd );
    HDC  hMem     = CreateCompatibleDC( hDC );
    RECT srcRect;
    RECT rct;
    HBITMAP hBmp, hOldBmp;
    srcRect.top    = hb_parvni( 2, 1 );
    srcRect.left   = hb_parvni( 2, 2 );
    srcRect.bottom = hb_parvni( 2, 3 );
    srcRect.right  = hb_parvni( 2, 4 );

    //GetWindowRect( hWnd, &rct );
    rct.left = 0;
    rct.top = 0;
    rct.right = srcRect.right - srcRect.left;
    rct.bottom = srcRect.bottom - srcRect.top;

    hBmp    = CreateCompatibleBitmap( hDC, rct.right, rct.bottom);
    hOldBmp = ( HBITMAP ) SelectObject( hMem, hBmp );

    BitBlt( hMem, 0, 0, rct.right, rct.bottom , hDC, srcRect.left, srcRect.top, SRCCOPY );

    SelectObject( hMem, hOldBmp );
    DeleteDC( hMem );
    ReleaseDC( hWnd, hDC );

    fw_retnll( hBmp );
}
//----------------------------------------------------------------------------//
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: Print and save an Image

Postby Otto » Sun Mar 28, 2021 1:40 pm

Antonino, thank you for posting the solution.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6322
Joined: Fri Oct 07, 2005 7:07 pm

Re: Print and save an Image

Postby nageswaragunupudi » Sun Mar 28, 2021 2:14 pm

Not necessary.
There is already a function
Code: Select all  Expand view

MakeBkBmpEx( hWnd, top, left, width, height )
 

that does the same thing.

For the user, it is comfortable to use
Code: Select all  Expand view

oWnd:SaveAsImage( anyimagefile, [ { top, left, bottom, right } ] )
 

Image file can be bmp, jpg, png, etc.
I don't see any need to modify the FWH sources.
Regards

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

Re: Print and save an Image

Postby AntoninoP » Sun Mar 28, 2021 6:01 pm

I am using 18.01, these function are "new"
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 110 guests