paste one DC on second DC

paste one DC on second DC

Postby Natter » Wed Jun 05, 2024 1:40 pm

Hi,

I need to paste one device context onto another at the specified coordinates. How can I do this?
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: paste one DC on second DC

Postby Jimmy » Wed Jun 05, 2024 2:30 pm

you can use StretchBlt API function https://learn.microsoft.com/en-us/windo ... stretchblt

BOS Taurus of HMG have this :
Code: Select all  Expand view  RUN
//*****************************************************************************************************************************
//* BT_DRAW_HDC_TO_HDC (hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, Mode_Stretch, Action, Color_Transp)
//*****************************************************************************************************************************

// Action
#define BT_HDC_OPAQUE        0
#define BT_HDC_TRANSPARENT   1

HB_FUNC (BT_DRAW_HDC_TO_HDC)
{
   HDC hDC1, hDC2;
   INT x1, y1, Width1, Height1, x2, y2, Width2, Height2;
   INT Mode_Stretch, Action;
   COLORREF color_transp;
   POINT Point;

   hDC1          = (HDC)      HMG_parnl (1);
   x1            = (INT)      hb_parni (2);
   y1            = (INT)      hb_parni (3);
   Width1        = (INT)      hb_parni (4);
   Height1       = (INT)      hb_parni (5);

   hDC2          = (HDC)      HMG_parnl (6);
   x2            = (INT)      hb_parni (7);
   y2            = (INT)      hb_parni (8);
   Width2        = (INT)      hb_parni (9);
   Height2       = (INT)      hb_parni (10);

   Mode_Stretch  = (INT)      hb_parni (11);
   Action        = (INT)      hb_parni (12);
   color_transp  = (COLORREF) hb_parnl (13);


   bt_bmp_adjust_rect (&Width1, &Height1, &Width2, &Height2, Mode_Stretch);  

   //SetStretchBltMode (hDC1, COLORONCOLOR);
   GetBrushOrgEx (hDC1, &Point);
   SetStretchBltMode (hDC1, HALFTONE);
   SetBrushOrgEx (hDC1, Point.x, Point.y, NULL);

   
   switch (Action)
   {    case BT_HDC_OPAQUE:
             StretchBlt(hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, SRCCOPY);
             break;
        case BT_HDC_TRANSPARENT:
             TransparentBlt(hDC1, x1, y1, Width1, Height1, hDC2, x2, y2, Width2, Height2, color_transp);                                                        
             break;    
        default:
             hb_retl (FALSE);        
             return;
   }

   hb_retl (TRUE);
}

 
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: paste one DC on second DC

Postby Natter » Wed Jun 05, 2024 3:44 pm

Thanks, Jimmy, I'll try.
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: paste one DC on second DC

Postby Natter » Thu Jun 06, 2024 10:24 am

Jimmy, I compiled your example. References to bt_bmp_adjust_rect and HMG_parnl are not recognized
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

Re: paste one DC on second DC

Postby Jimmy » Thu Jun 06, 2024 10:38 am

hi,
Natter wrote:Jimmy, I compiled your example. References to bt_bmp_adjust_rect and HMG_parnl are not recognized

replace HMG_parnl() with hb_parnll()

you will find HB_FUNC( STRETCHBLT ) in Fivewin \source\winapi\bmpdraw.c
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: paste one DC on second DC

Postby Natter » Thu Jun 06, 2024 10:45 am

Thanks !
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 47 guests