PDA

Click to See Complete Forum and Search --> : layered painting in a picturebox


opus
Jul 2nd, 2001, 12:47 PM
I want do do layered painting in a picturebox,
but I can't figure out how to get the top layers transparent.
For example on layer 1 should be the background colour/picture, layer2 should have some lines, layer3 some circles.
Can anyone give me a little help?
Thanks

Sastraxi
Jul 2nd, 2001, 01:02 PM
The only real way to do this would be to use DDraw, but, then again, that is a little advanced (maybe?). You can also use BitBlt to make your drawings transparent, if you don't know bitblt I can give you a link to my tut.

opus
Jul 2nd, 2001, 01:08 PM
I'm using BitBlt, but not with a transparent background.
But whow do I handle the differnt layers? Whow do I store them?

Sastraxi
Jul 2nd, 2001, 02:38 PM
My suggestion is make a UDT that stores an hDC, X, Y, Width, Height, and Layer. Then you can put in something to blit an array of that UDT, in the correct layer order. That's what I would do.

opus
Jul 2nd, 2001, 02:44 PM
UDT= User Defined Type
I'm getting the point, hopefully ;-)
Thanks for the help I'm off for some studying

BTW could you send me the link for transparent bitblt?

Sastraxi
Jul 2nd, 2001, 03:25 PM
http://vbden.tripod.com/articles/invmask.htm

opus
Jul 3rd, 2001, 04:27 PM
:mad: I've done something that looks like what I want to have, but is it really neccessary to draw each "Layer" twice?
Here is what I do:
Picturebox(0) is the background (autoredraw false all other pictureboxes have autoredraw true and visible false)

picturebox(1) and ..(2) have to have the drawings of one layer (the drawings are identical exept for the colours), with ..(1) as the mask and ..(2) as the sprite. After drawing those two I can BitBlt then onto picturebox(0) as if ..(2) would have a transparent background.

IS THAT REALLY NECCESSARY???????????? To me it look's a bit overdone!

Sastraxi
Jul 3rd, 2001, 04:33 PM
No. The 'mask' sets which colour bits are transparent. Then the sprite gives the colour information. If you did it once then you would either have no transparency or a black silouhette.