Results 1 to 7 of 7

Thread: Masking A Certain Colour

  1. #1

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444

    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

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    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.
    Involved in: Sentience

  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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)
    Sanity is a full time job

    Puh das war harter Stoff!

  4. #4
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    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.
    Involved in: Sentience

  5. #5
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    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...
    Sanity is a full time job

    Puh das war harter Stoff!

  6. #6

    Thread Starter
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    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.

  7. #7
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Oregon
    Posts
    962
    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.
    Involved in: Sentience

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width