Programs - Bmp Viewer


Aim

This program did not develop out of necessity but out of ingenuity. Someone else who was doing Computer Science had started to develop a bmp viewer and had not got it working exactly correct. He asked me for help with the program and I proceeded to write a whole unit for displaying bmp files.

Method

Windows bitmaps are weird, they are stored bottom to top. That means that if you display it as you read it, it swipes upwards! The other thing is that for 16 colours, each byte that you read in contains two pixels. However 256 colours is easy because each byte is a pixel.

At the beginning of the bmp file, is all the information like: height, width and number of colours. Then comes the colour palette for index-colour images, i.e. anything up to 256 colours. After all of that is the actual data for the image, which can be processed and shown immediately.

What makes the program so useful is the browser - viewer combination. I built a browser around the unit, so that I could navigate around a disk easily to find pictures to view. The browser is a full screen list of all the navigable files and directories in the current directory. It’s as simple as navigating around and pressing enter.

When you select a bmp file the program uses the bmp unit to get information about the picture. That includes: height, width, colours, and planes - Whatever they are. I think they’re like separate levels in the image. You then get a choice on how to display the image. Whether to centre it, put it in the top left hand corner - normal, or to tile it - as you would a background. After displaying the picture(s) it waits for a key to be pressed and then returns you to the browser.

This program was a challenge at the time. It taught me much about graphics palettes and file access. It was an interesting project that is still in use today.