Monday, August 29, 2005

PNG: superior transparency

After using PNG graphic format (pronounced as "ping") a little, I already noticed its technical advantage. It is patent-free, endorsed by W3C and it is actually meant to replace GIF and TIFF, but it is not yet supported by every application (including browsers). One of the key features, in my opinion, is the alpha transparency, since it allows binary and variable transparency. Therefore, a PNG image will look great on different backgrounds, while a GIF will not. For this reason, that was the format I had chosen for the images I use in my web application, but I hadn't tested it in Microsoft Internet Explorer. I ended up finding out that it does not support PNG alpha transparency, although Firefox and most of other browsers support it. Therefore, I had two options:

a) Use a JavaScript to fix this problem in IE (see link).

or

b) Change every transparent PNG to be a indexed image with a matte matching the background color I am using.

The former option seemed the most natural, but I din't like the effect it added to the page when it was displayed (it showed the image not transparent and then it made it transparent using some DirectX features). So I had to manually convert the images to make this application work in the most used browser.

Some resources where I found the information mentioned here:

1. The PNG File Format
2. Portable Network Graphics
Post a Comment