HTML and CSS Reference
Figure 21-2. Photos taken at various locations around Google's Mountain View campus
Look at Table 21-1 . Which two formats can you quickly take out of the running?
Table 21-1. Files Sizes of Various Browser-supported Formats
Every browser supports BMPs, but they're almost never used, and Table 21-1 demonstrates why. BMPs are raw,
uncompressed RGB data. As such, they make for pretty huge image files. If you need lossless data, PNGs are always
smaller and support an alpha channel, so there's no good reason to use BMP.
GIFs are an odd historical artifact that refuses to die. Sporting unimpressive compression and palletized color, their
only upside (animation) is not one that WebGL can use effectively. Don't even bother with them for 3D content.
The rest of the image formats have pros and cons, and which one you use depends on your needs.
PNGs have several things going for them. First of all, they're lossless, which is very important for certain types of
texture information like normals. They can also store an alpha channel, which is obviously necessary for transparent
textures, but it can also be used to store extra data channels like specular information if transparency is needed. This
makes PNGs very versatile and, as such, they tend to be the default choice for many WebGL applications. You can
see from Table 21-1 , however, that the resulting images can still be fairly large, which is something that needs to be
weighed against the technical benefits. If you do find that you need to use PNGs I recommend looking at tools like
http://pngcrush.com to reduce their size.