CPSC 461: Copyright © 2002 Katrin Becker 1998-2002 Last Modified October 20, 2001 10:03 PM

FILE FORMATS REVIEW QUESTIONS

SHORT ANSWER QUESTIONS

1. [ 3 marks ] What is it about images for scientific applications that distinguishes them from other graphical images?
2. [ 4 marks ] Is there any way to digitize an analog audio signal that does NOT result in the loss of data? Explain why.
3. [ 3 marks ] What is a perceptual codec?

LONG QUESTIONS

1. [10 marks]
   Given the following C structure for the header of a BMP graphics file:
   struct bmpHeader
   { // Start of File Header
   byte magic1, magic2; // must be ‘BM’
   long filesize; // bytes in file
   short res1, res2; // reserved = 0
   long pixelOffset; // file position where data is
   // Start of Bitmap Header
   long bmpsize; // size of bit map info header
   long cols, rows; // image size
   short planes; // planes = 1
   short bitsperpixel; // 1, 4, 8, 24
   long compression; // RGB, RLE4, RLE8
   long cmpsize; // size of compressed image = 0 for RGB
   long xscale, yscale; // EG pixels per meter
   long colors; // #colours used
   long impcolors; // # of important colours
   } bh;
   Some important facts about BMP images:
   1. Images in BMP files are stored ‘upside down’, meaning that the first row of pixel data is actually the LAST row of the image. Column 1 is still first in each row.
   2. Each row is padded to a 4-byte boundary (i.e. the pixel data for each row begins on a 4-byte boundary (word boundary on UNIX).
   Assuming we have a BMP image that is 24-bit; RGB (uncompressed), write the code necessary to read the image into memory. Declare whatever structures you require. You may assume the header has already been read into bh. You may also assume the existence of a function called getbyte() that reads and returns the next single ‘raw’ byte read from the file.

CPSC 461: Copyright © 2002 Katrin Becker 1998-2002 Last Modified October 20, 2001 10:03 PM