GDI allows to create pattern brush (from 8x8 bitmap for example). Such brush
will fill polygons with some pattern (like GDI defined hatch styles).
How to make such polygon transparent ?
Thanks in advance
Piotr
If you don't want any fill then select a null brush into the DC before drawing to it - You can get this using
GetStockObject(NULL_BRUSH);
If you want to fill with a Bitmap with transparent area's in then you've got a little more work to do - You'd need to create a mask
bitmap as a pattern brush from the transparent colour, have a look at the code from my ChromaBlt() method for an example of how to
create this; there's a VB library on my page or the C++ version here:
http://groups.google.co.uk/groups?selm=unyVYaaMDHA.704%40tk2msftngp13.phx.gbl
You'd then need to select this pattern brush into the DC and set a SRC_AND equivalent ROP2 mode (sorry I don't have the
corresponding R2_* mode handy, basically you want it to only draw the black area's of the mask so as to 'cut out' a hold in the
image - effectively a bitwise AND) and draw your first polygon.
Then create a second pattern brush from your original Bitmap but with the transparent areas filled with black then use a SRC_PAINT
equivalent ROP2 mode (bitwise OR against the existing image) over the top. I'd use a null pen for the first call so as to not waste
time drawing the border twice and be sure to call SetBrushOrgEx() before both calls to make sure the two brushes line up correctly.
(Note; the above is only in theory, I've never tried it before..)
Hope this helps,
Mike
- Microsoft Visual Basic MVP -
E-Mail: ED...@mvps.org
WWW: Http://www.mvps.org/EDais/
To follow-up on the ambiguities on the previous post after a bit of testing, the binary ROP modes you want are R2_MASKPEN (DPa) for
the mask ROP and R2_MERGEPEN (DPo) for the colour ROP - The technique seems to work nicely!