Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Matsen

Like Bitblt, but not

This topic is 5953 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! I'm trying to draw a bitmap to a DC and at the same time replace a color in the bitmap with another. Very simple, but I can't find a windows-routine which does this. I've looked at MaskBlt. TransparentBlt etc, but they are not what I want. My code is veeery slow. Take a look at it and you'll see what I'm trying to do...
    
COLORREF clr;
for (int i=0; i<cy; i++)
{
    for (int j=0; j<cx; j++)
    {
	clr = GetPixel(this->hdc, j, i);
        // if color == mask color then use background color

	SetPixelV(hdc, x+j, y+i, (clr == crMask ? bgColor : clr));
    }
}
  
Any suggestions on how to do this better/faster? Note, I don't want to change the original DC (this->hdc). Best regards Mats Edit: hard to get the code nice... [edited by - Matsen on June 2, 2002 4:29:59 AM] [edited by - Matsen on June 2, 2002 4:41:07 AM]

Share this post


Link to post
Share on other sites
Advertisement
TransparentBlt doesn''t copy the transparent color, so PatBlt the transparent color before you TransparentBlt the bitmap.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!