-
Masking A Certain Colour
Hi, I asked this before in the General board but didn't really get an answer, so I thought I'd try here. I'm making a user control up, and I want to be able to draw a picture onto the control, and have all of a particular colour transparent. If you know what I'm talking about please help :D
-
One easy (but extremly slow) way of doing this would be to loop though the entire image, then replace all of that color with white (saving the image to a memory DC [mDC] as you go), and at the same time making a mask in a diffent mDC. Then just bitblt that same image to a picture box or the control form. The major problem with this is that you woun't see though the control.
If you wish to be able to see the object the control is on, you may be able to punch a hole though the control (search the forums), based on the colors of the pixels as you loop though them.
I don't know how helpful this will be, but this is all I can think of.
-
well since buttons already support this you might just want to misuse a button for this... this might not work for you though (probably not)
so I can't really think of a much better way than gamingworld except for doing all of the replacing and blitting afterwards I would rather copy it pixel by pixel to the destination except for the unwanted color and (should take up the same time for the looping through but it saves the blt afterwards)
-
The reason I said to do it the way I did, was beacuse my way you don't have to redo the loop if the image needs to be redrawn, just reblt the image.
-
well with autoredraw = true that works...
but didn't you want to get the transparency while blitting? Don't you need a mask for that too? Would make 2 looping throughs...
-
Thanks for the suggestions. I had thought of creating a mask by looping through all the pixels, but I thought maybe there was a quicker/easier way.
-
It is possible to get both the mask and the image transfered into memory DCs with one loop. Then you just blt the mask and the image onto the viewable dc.