|
|
|
date: Tue, 04 Mar 2008 12:34:10 +0000,
group: microsoft.public.platformsdk.gdi
back
Clipping changes mask origin in MaskBlt???
I have a monochrome bitmap I want to use as a stencil to paint colour
onto a DC surface, and I'm using MaskBlt to do it. This works fine
/unless/ I set a clip region in the DC, whereupon the stencil seems to
shift its origin.
IOW, I have code that goes roughly,
HDC hdc = ...
#if USE_CLIP
HRGN hrgn = ...
SelectClipRgn (hdc, hrgn);
#endif
// set the colour to paint
LOGBRUSH lb = { BS_SOLID, colour, 0 };
HBRUSH hb = CreateBrushIndirect (&lb);
SelectObject (hdc, hb);
// paint through the stencil mask
HBITMAP hbm_stencil = ...
int x, y, w, h = ...
unsigned rop4 = 0xAAF00000;
MaskBlt (hdc, x, y, w, h, hdc, 0, 0, hbm_stencil, 0, 0, rop4);
(The rop4 code means to copy the brush where the mask is 1 and leave the
destination unchanged where the mask is 0.)
If the clip region is not set, this does exactly what I expect, but if
it is, then the resultant image is not only clipped but displaced too.
It's almost as if the mask coordinates were offset to the start of the
clip region.
Has anyone seen anything like this before? Is there another simple way
to get stencil functionality?
Many thanks,
Steve Rencontre
date: Tue, 04 Mar 2008 12:34:10 +0000
author: Steve Rencontre et
Re: Clipping changes mask origin in MaskBlt???
Steve Rencontre <spam@bit.bucket> wrote:
>
>I have a monochrome bitmap I want to use as a stencil to paint colour
>onto a DC surface, and I'm using MaskBlt to do it. This works fine
>/unless/ I set a clip region in the DC, whereupon the stencil seems to
>shift its origin.
>...
>If the clip region is not set, this does exactly what I expect, but if
>it is, then the resultant image is not only clipped but displaced too.
>It's almost as if the mask coordinates were offset to the start of the
>clip region.
>
>Has anyone seen anything like this before?
My guess is that you have found a buggy display driver. Have you tried
this on any other computers?
>Is there another simple way to get stencil functionality?
If you are just painting a solid color, you can do this with a pair
straight 2-op BitBlts. Draw the mask with R2_MASKNOTPEN with colors white
and black (which will dig the hole), then draw it with R2_MERGEPEN with
colors black and whatever color you want to use to fill.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
date: Tue, 04 Mar 2008 23:01:07 -0800
author: Tim Roberts
|
|