Archived

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

hammerstein_02

ColorKeying

Recommended Posts

SDK: DirectDraw7 Language: C++ Quick overview of what I am doing.. I have an animation object, basically I use two directdrawsurfaces one for the main, then cut the piece out of it for the frame of animation which I return to my drawing object. I use BltFast to put the source image onto my destination one and then return that surface. What I want to do is have a transparent colour, so I have written a function in my graphics object like so:
  
bool cGraphics::SetSurfaceTransparency(LPDIRECTDRAWSURFACE7 surf, int r, int g, int b)
{
	DDCOLORKEY	ddcKey;

	if(surf)
	{
		ddcKey.dwColorSpaceHighValue = RGB(r,g,b);
		ddcKey.dwColorSpaceLowValue = RGB(r,g,b);

		if(FAILED(surf->SetColorKey(DDCKEY_SRCBLT, &ddcKey)))
			return(false);
	}

	return(true);
}
  
So I call this from my animation object with my drawing surface (the one I blit too) and nothing.. nothing appears on the screen. My drawing procedure doesn''t fail:
  
	if(FAILED(m_lpDrawSurface->BltFast(0,0, m_lpMainSurface, &srcRect, m_Flags)))
		{
			sprintf(buffer, "Animation failed");
			return(NULL);
		}
  
because nothing appears in my log file. PLease help me, what am I doing wrong? =*= If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore =*=

Share this post


Link to post
Share on other sites
I got it working eventually, it came down to the colour.

It was 0,67,171

I changed it to 255,0,255

and it worked.. go figure.. what was I doing wrong?

=*=
If things seem bad, think that they can get a whole load worse, and they don''t seem so bad anymore

=*=

Share this post


Link to post
Share on other sites
using the rgb macro isnt compatible with all bitdepths...certain values like 0,0,0 or 255,255,255 will always work because it will just come out to be a max or minimum value, which happens to be white and black in all bit depths. I''ve seen a few methods for getting around this...you can get the pixel format for yourself, or you can plot a pixel the color you want to use then get that value from the surface...something like that, but you can always be safe with black

Brian

Share this post


Link to post
Share on other sites