Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Direct Draw Scaling Surfaces In 16-bit+ Color Modes

Status
Not open for further replies.

InTheSackMan

Programmer
Jul 16, 2003
1
US
Hey, this problem has been bugging me for a while now. I want to be able to dynamically change the size of the sprites in a DirectDraw game I'm making, without having fifty textures for each sprite. I found that you can blit in a box larger or smaller than the original sprite and DirectX will resize it for you. My problem is that the transparency color i'm using ( hot pink, RGB(255, 0, 255 ) ) seems to mesh with this and when I change the size of my sprites they all have a pink outline around them! It seems that directdraw is using the transparent color for the stretch operation and averaging a bit, i.e RGB(252, 0, 253) and changing it to that..which isn't set as transparent. This doesn't seem to happen when I'm in 8 bit palettized mode but thats not the mode I want! I tried other transparent colors and the same happens, it puts an outline around the sprite with that color. Is there a way to tell directX that I don't want it to use the transparent color when it averages out the pixels or whatever it does without specifying multiple color keys? Or am I going to have to change the name of my game to "pretty pink ponies"? Thanks, I know this was a long post.
 
Hi!

The color key is just an information that tells DX if it recognize CK during Blit do not copy that pixel. But CK colored space is part of your image plane, and if you resize it DX will smooth that color with other pixels.

There are two way to solve this.

1. Ugly but fast:

Do not use any filtering method during resize (e.g. LINEAR).

2. Slower but best quality (DX8+ or DX7+? dont remember):

Use ARGB pixel format instead of color key. Save your images to file format that support alpha channel (I prefer PNG. load it to ARGB surface (with D3DX Library or pnglib), and let DX do the resizing work with any filtering method.

Good luck,

Unborn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top