Sign in to follow this  
Susan-gt

PNG help???

Recommended Posts

I was looking over the donuts demo in 9.0b sdk and found that microsoft uses a png file to overlay a user interface at the end of there renderings. Looked at the png file and it looks like it has transparent pixels in it. What is a png file? And how can we use them to create transparent overlays (p.s. the donut demo is way to complicated for me to try to use code from it). Any one know of a simple tutorial that uses them? Or a web page that explains them? Or an article?

Share this post


Link to post
Share on other sites
There's not much you need to know. PNG is a image file format, which is good for compressing non-photo images, and it can have transparency in it.
You can use D3DXCreateTextureFromFile() to load a PNG file into a texture surface. I've never had a use for file formats with transparency, I usually just use colour keying with D3DXCreateTextureFromFileEx().

Share this post


Link to post
Share on other sites
Evil Steve is spot on.

Further, PNG images let you do proper transparency rather than keyed transparency: A keyed transparency image uses a praticular colour to represent how transparent a pixel is.

Imagine a sprite which fades from white to transparent. That would be a white -> black fade in a keyed image... but say you want to do a smoke sprite which fades from black to transparent.. sure, you could use another key.. but that's something you won't need to worry about with PNG.

Since PNG's have true transparency (any colour can be any level of transparent).

And a tip: In my experience Adobe Photoshop's PNGs won't display correctly as transparent sprites in DirectX. Use Macromedia Fireworks (others?) instead.

Share this post


Link to post
Share on other sites
Right, Photoshop writes any pixel that is transparent (alpha=0) as (255,255,255,0) regardless of what color you'd like to be there. This messes things up in Direct3D where pixel colors are interpolated if you use mag/min filters. You'll notice a white fringe around your sprites if you use Photoshop to save PNG files.

I now have a pipeline where I edit files in TGA or TIF and then convert to PNG before distributing. Too bad Photoshop doesn't work correctly with the best image format in existence and that we have to do things like this.

(In versions 6.0 or earlier, at least, TGA/TIF files display alpha information as a separate "channel". PNG files -should- work like this also but don't, they use Photoshop's internal "transparency" instead, which is like a crippled alpha channel.)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
[quote]Original post by MasterWorks
Right, Photoshop writes any pixel that is transparent (alpha=0) as (255,255,255,0) regardless of what color you'd like to be there. This messes things up in Direct3D where pixel colors are interpolated if you use mag/min filters. You'll notice a white fringe around your sprites if you use Photoshop to save PNG files.

hOW BOUT gimp? dOES THERE PNG FILES WORK?

Share this post


Link to post
Share on other sites
I have not used GIMP but I think it works properly. There is a mention of the Photoshop problem on the PNG specs homepage, check if it says anything about <your editor of choice>!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this