Graphics File Formats
There are many different types of graphics files, ranging from the common, like The Windows Bitmap (identified by the file extension), Graphics Interchange Format/GIF (.gif), Joint Photographics Expert Group format/JPEG (.jpg) and Portable Network Graphics (.png) to hundreds of obscure formats.
Ways of Storing Graphics
There are two principal kinds of graphics formats, vector graphics and raster graphics.
Vector Graphics
Sometimes, computer graphics are stored as a series of instructions, to draw certain polygons in certain places with certain colours. Vector graphics files are normally relatively small in size.
Raster Graphics
However, more frequently, graphics are stored as a series of dots of colour (Unless it's an American computer, in which case it stores a series of dots of color). These dots of colour are known as pixels. Raster graphics files are normally relatively large in size.
Which is better?
As vector graphics normally require far less storage space, simplistically one would say that vector graphics are better. However to adopt this position would be like saying "a car is always better than a lorry because it consumes less petrol/gas. A car may require less petrol, but a large item that needs to be moved might not fit in it. Raster files, despite their size are useful for storing photographs. This is because a digital photograph is a discrete sample of a continuous function (i.e. if you drew a graph of something you see in terms of its constituent colour parts it would be a curve, whereas when you take a photograph and store it on a computer, points along that curve are stored, as the exact function of the image can never be ascertained.
Q. Can a photograph be stored in vector format? A. Yes and No. You cannot store the function of a photograph in vector format, however, if you wished to, you could store a series of instructions to draw each individual pixel in a vector format. This however would be very inefficient.
Why Are There So Many Graphics Formats?
You may now be wondering, if there are only two different ways of storing graphics, why are there five or six different formats. The answer is simple: compression. Of the four mainstream graphics formats (BMP, JPEG, GIF and PNG), all four store information in raster format. Raster files are very large, which is a large problem when they are exchanged over the internet, therefore, each type of file differs in the way it compresses its data. Below is a brief description of the compression method used by each format and what it is useful for:
BMPFormat: Developed by Microsoft. Uses no compression. Lossless. Pixels can have a range of 2 - 16777216 different colours.
GIFFormat: Developed by Compuserv. Uses a method of compression known as LempelZivWelch. Pixels can have a range of 1 - 256 different colours. A lot of people dislike using GIFs because a company named UniSys began sueing those who write programs that generate GIFs. They were able to do this because Compuserv used a patented compression algorithm. See http://burnallgifs.org/.
JPEGFormat: Developed by the Joint Photographics Experts Group. Uses two methods of compression, RunLengthEncoding and the DiscreteCosineTransformation (a variation of the FourierTransformation).
PNGFormat: Developed by the PNG Development Group. Uses DeflateCompression (Based on the general .zip file format). It is often seen as the alternative to GIFFormat.
TGAFormat: Developed by TrueVision Corporation. Has support for RunLengthEncoding compression, but rarely used. Stores 8 through 32 bit depth images, and is mostly useful due to its wide support and extremely simple file format. Can't stress it enough - highly recommend it for graphics coding when you don't want to work hard at loading/saving.
XPMFormat: Developed mostly by Arnaud Le Hors. Unique in the respect that it can be easily compiled into your program (or kept externally). Not an official part of the X Consortium, it is still a widely acknowledged standard, more information: http://koala.ilog.fr/lehors/xpm.html.
