paste one DC on second DC

Post Reply
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

paste one DC on second DC

Post by Natter »

Hi,

I need to paste one device context onto another at the specified coordinates. How can I do this?
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: paste one DC on second DC

Post by Jimmy »

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

BOS Taurus of HMG have this :

Code: Select all | Expand

//*****************************************************************************************************************************
//* 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
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: paste one DC on second DC

Post by Natter »

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

Re: paste one DC on second DC

Post by Natter »

Jimmy, I compiled your example. References to bt_bmp_adjust_rect and HMG_parnl are not recognized
User avatar
Jimmy
Posts: 1733
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: paste one DC on second DC

Post by Jimmy »

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
Natter
Posts: 1226
Joined: Mon May 14, 2007 9:49 am

Re: paste one DC on second DC

Post by Natter »

Thanks !
Post Reply