Archived

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

s_cloudx

How do I block a certain color when bliting?

Recommended Posts

Create a surface image of your character and replace all non-transparent pixels with a near black colour. Use this instead of your normal surface image in DirectDraw, or use as a texure in D3D. Try doing it in Paintshop with a high colour tolerance fill.

If I understand your question correctly you do not want to block a colour, you want to replace a range of colours with one near black colour.

,Jay

Share this post


Link to post
Share on other sites
Yeah, this is just color replacement.
What I would do(if you want it to be done in-game), would be to
make a temporary surface, lock it and the source surface and then
read each pixel on the source surface. After each read, you''d
check to see if the pixel is a transparent color(as in, one that
doesn''t get blitted). If it IS, copy it over, if it ISN''T a
transparent pixel, then change the pixel color to near-black.

Make sense?

-Hyatus
"da da da"

Share this post


Link to post
Share on other sites
OHH...
Just hit me what you''re trying to do.

Okay, let''s see.

There are two other ways to do this.

One, make a surface and fill it with near-black.
Then, lock and copy over all the pixels that are transparent.

The other(very similar) way, would be to make a surface, fill it
with near-black, and then blit the other surface over, only, make
the range of values for the blit every color from just above your
black color, to white.

That last way would be speedy.

-Hyatus
"da da da"

Share this post


Link to post
Share on other sites
Look up color keying in the DX sdk...
Basically, make your surface and blt the bitmap onto it.
Then, make another surace exactly the same size and color
depth.

    
DDBLTFX ddBltFx; //BLTFX structure

RECT fill_area; //The area that's too be filled


ZeroMemory(&ddBltFx, sizeof(DDBLTFX)); //clear struct

ddBltFx.dwSize = sizeof(DDBLTFX); //set the size of struct


ddBltFx.dwFillColor = 0; //color = black


fill_area.top = 0;
fill_area.left = 0;
fill_area.right = Width; //width of the surface

fill_area.bottom = Height; //height of the surface


lpDDStruct->Blt(&fill_area, NULL, NULL, DDBLT_COLORFILL, &ddBltFx); //lpDDStruct is the surface you're filling



You should set a colorkey to one color above black and all the
way to white(if your src color key is black) and attach it to
this surface...

Then, blit the other surface onto the destination one using a
destination colorkey blit(DDBLT_KEYDEST as opposed to DDBLT_KEYSRC).

Make sense?

-Hyatus
"da da da"

Edited by - hyatus on February 18, 2002 12:42:02 AM

Share this post


Link to post
Share on other sites