Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
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

Re: Clipping changes mask origin in MaskBlt???   
Tim Roberts wrote:

> My guess is that you have found a buggy display driver.  Have you tried
> this on any other computers?

I'd come to a similar conclusion, that it was a GDI or driver bug. I've 
not tried it on another machine 'cos I needed it to work more than I 
needed to understand why it didn't work, but I intend to do so when I 
have some time.

>> 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.

Thanks for that, but I've now used a different method. I create a 
rectangular bitmap filled with solid colour and use that as a direct 
source for the MaskBlt. Metaphorically, I no longer have a paint brush 
and a stencil but an ink pad and a rubber stamp :-)

All the best,

Steve Rencontre.
date: Wed, 05 Mar 2008 11:06:46 +0000   author:   Steve Rencontre et

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us