FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Print and save an Image
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Print and save an Image
Posted: Sat Mar 27, 2021 05: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 March-April 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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 04: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
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: Print and save an Image
Posted: 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 March-April 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
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 01:02 PM

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

Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 01: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 (cpp): Select all Collapse
<div class="cpp" id="{CB}" style="font-family: monospace;">//---------------------------------------------------------------------------//
// 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 );
}
//----------------------------------------------------------------------------//</div>
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 01:40 PM

Antonino, thank you for posting the solution.
Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 02:14 PM
Not necessary.
There is already a function
Code (fw): Select all Collapse
MakeBkBmpEx( hWnd, top, left, width, height )

that does the same thing.

For the user, it is comfortable to use
Code (fw): Select all Collapse
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
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: Print and save an Image
Posted: Sun Mar 28, 2021 06:01 PM

I am using 18.01, these function are "new"

Continue the discussion