• Advertisement

Archived

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

DirectDraw, C#, ColorKey

This topic is 5490 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

Sorry for the newbie question, but whats the correct thing to do here: ColorKey ck = new ColorKey(); // Create a new colorkey. surfaceAnimation.SetColorKey(ColorKeyFlags.SourceDraw, ck); // Set the colorkey to the bitmap surface. 0 is used for the colorkey, which is what the ColorKey struct is initialized to. I want to change the colorKey to magenta (255,0,255). How do I do that in C#? There were macros to create colors, or I could just use 0xFFFF00FF in C++ / DX8. I cant figure what to do in C# (using unchecked code for 0xFFFF00FF doesnt work). I know you have to set ColorSpaceHighValue and ColorSpaceHighValue, just not sure how to do that. Thanks Ratman

Share this post


Link to post
Share on other sites
Advertisement
Took me a while to figure out (since the documentation sucks):



ck.ColorSpaceHighValue = ColorTranslator.ToWin32(Color.Magenta)
ck.ColorSpaceLowValue = ColorTranslator.ToWin32(Color.Magenta)



[edited by - FieroAddict on February 8, 2003 11:56:21 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by FieroAddict
Took me a while to figure out (since the documentation sucks):



ck.ColorSpaceHighValue = ColorTranslator.ToWin32(Color.Magenta)
ck.ColorSpaceLowValue = ColorTranslator.ToWin32(Color.Magenta)



[edited by - FieroAddict on February 8, 2003 11:56:21 AM]


To do this with slightly less typing you can do:


ck.ColorSpaceHighValue = Color.Magenta.ToArgb();
ck.ColorSpaceLowValue = Color.Magenta.ToArgb();


-- Exitus Acta Probat --

Share this post


Link to post
Share on other sites
Argh, ok maybe this doesnt work like I thought. I changed the colorKey like above and I cant get other colors to be "transparents" (not drawn). Yet when I switch the value black pixels are now draw - which they werent before.

Does MDX support color keying like this? Or am I going to have to use alpha channels? It would be really nice if I could just specify the color not to draw. Can anyone help?

Thanks
Ratman

Share this post


Link to post
Share on other sites
Are you using Drawfast? Both methods work for me.... try a color like White, or Red or something generic. Maybe the Magenta doesn''t correspond to the actually shade of color in your graphics.


back.DrawFast(destRect.X, destRect.Y, mySprite, spriteRect, DrawFastFlags.DoNotWait Or DrawFastFlags.SourceColorKey)

Share this post


Link to post
Share on other sites
quote:
Original post by FieroAddict
Are you using Drawfast? Both methods work for me.... try a color like White, or Red or something generic. Maybe the Magenta doesn''t correspond to the actually shade of color in your graphics.


back.DrawFast(destRect.X, destRect.Y, mySprite, spriteRect, DrawFastFlags.DoNotWait Or DrawFastFlags.SourceColorKey)



Yeah Ive tried a few different colors just to be sure, and its not working. Anyone got an example or something?

Share this post


Link to post
Share on other sites

  • Advertisement