Flag of Sweden
Andreas Rejbrand’s Website

Advanced authoring in Microsoft Word – Part 22: Introduction to bitmapped (raster) graphics

You often want to include images in Microsoft Word documents. Very often, images are bitmapped (or raster graphics images), that is, they are represented in the computer as a two-dimensional grid of pixels (of various colour). For example, a typical modern digital camera might produce bitmapped images sized 4752×3168, and a screenshot of a computer display may be of size 1920×1080. There are many digital file formats that can be used to store bitmapped images, the most common being BMP, JPEG, GIF, PNG, and TIFF.

BMP is an old file format introduced in early versions of Microsoft Windows. There is (typically) no compression, so files are very large. A BMP file of size 4752×3168 with a normal colour depth of 24 bits per pixels (that is, 3 bytes per pixel, or one byte per RGB channel and pixel, so e.g. the red component of a pixel is a number between 0 and 255) will be larger than 43 megabytes (almost all of this being due to the actual pixel data, but BMP files also contain a small file header).

A much better choice for photographs is the JPEG file format. This format is specifically designed to store photographic images. It uses advanced mathematical techniques to compress the image data. The compression is lossy, meaning that information is permanently lost during compression. However, the format is designed so that the loss of visual quality of a typical photographic image is barely noticeable to a human viewer. At the same time, the file size is greatly reduced. In the above example, the BMP file had a file size of 43 megabytes. The same photograph, saved in the JPEG file format with a small level of lossy compression, will only be 6 MB. And the loss of quality is (almost) invisible to a human viewer.

Warning! As mentioned above, the JPEG file format is specifically designed so that the loss in image quality will be almost invisible to the human eye in photographic images. However, the loss of quality will be very visible in non-photographic images! For example, it is a terrible idea to save diagrams, computer screenshots, and images containing (computer) text in the JPEG format, since precise thin lines and solid-colour regions will be very visibly distorted by the compression. Again: JPEG compression is only suitable for photographic bitmapped images!

In the following example, a screenshot of a Microsoft Word document is displayed without lossy compression (the first image), and (incorrectly) with JPEG compression (the second image). Notice how horrible the second image looks!

An uncompressed screenshot from a Microsoft Word document.
An uncompressed screenshot from a Microsoft Word document.
A JPEG-compressed screenshot from a Microsoft Word document.
A JPEG-compressed screenshot from a Microsoft Word document. (Incorrect!)

If you have subpar vision or a bad computer display, the difference might not be as obvious as it would be otherwise. But you probably can see the difference in the following magnifications (uncompressed and JPEG compressed):

An uncompressed screenshot from a Microsoft Word document (closeup).
An uncompressed screenshot from a Microsoft Word document (closeup).
A JPEG-compressed screenshot from a Microsoft Word document (closeup).
A JPEG-compressed screenshot from a Microsoft Word document (closeup).

So, should you use BMP instead of JPEG when it comes to bitmapped images containing non-photographic data such as diagrams and screenshots? No, instead you should use the PNG file format.

The PNG file format is a modern file format used to represent bitmapped images. It is compressed, but the compression is lossless, meaning that no information is lost during compression. Hence, there is never any loss of quality (or even any change to the image data at all) during compression and decompression. Hence, PNG is perfect to use for non-photographic images such as diagrams and screenshots, and, more generally, images containing areas of solid colour, precise discrete curves, and text.

For example, the previous example image (containing a part of a Microsoft Word document) has dimensions 672×240, so if saved as a 24 bpp BMP file, it would require more than 440 kB of data. On the other hand, if saved as a PNG image, it will only require about 9 kB. And there is absolutely no loss of quality.

What about GIF? Well, GIF is generally an obsolete format. Like the PNG format, it employs lossless compression, so it is suitable for the same type of graphics as the PNG file format. However, a single bitmap frame inside a GIF image can only contain 256 distinct colours, which is a severe restriction. But to compensate, a GIF image may contain several different frames, which makes it technically possible to represent full-colour images (although it is awkward). Unlike PNG images, GIF images can be animated (different frames are rendered in succession in time), so GIF images are still used for simple animations on the Internet. But for all other applications, PNG is a much better choice.

Finally, the TIFF file format is a rather advanced file format used in various software products to represent high-quality images, with or without lossy compression.

In conclusion, so far:

Show all news items.

Only show the most recent news items.