CS/ECE 545 Utility Software

Files:

These are programs or programs fragments which may be useful. Contributions in C, C++, or Java are welcome.

Standard Image Format

Here is a synopsis of the standard format for an image W pixels wide by H pixels high.

Header: 6 bytes of data. Three two-byte integers (high order byte first - "big endian" or "Motorola" encoding):

Bytes 1 -> 2: The number of Columns in the image (W). Valid values are 1 - 65535
Bytes 3 -> 4: The number of Rows in the image (H). Valid values are 1 - 65535
Bytes 5 -> 6: The number of colors. Valid values are 1 or 3.

The number of colors is 1 if the image is monochrome (gray scale) or 3 if the image is color. In that case there are three color planes stored in this order: Red (first), Green, Blue (last).

Bytes 7 -> (WxH + 6): Monochrome color data if the number of colors is 1.
 
Bytes 7-(WxH + 6): Red color data if the number of colors is 3
Bytes (WxH + 6 )-> (2xWxH + 6): Green color data
Bytes (2xWxH + 6 )-> (3xWxH + 6) Blue color data
 

The data are bytes read out in rows running from the top left. The printer's convention is used: 0x00 is white (or maximum amount of a color) and 0xFF is black.

Sample Images

Here are two images in standard image format and in TIFF format (converted using program img2tif.c described below). You will need to download the *.img files in binary format, but your browser might open the *.tif files directly.

   
leonardo1.img leonardo2.img
leonardo1.tif leonardo2.tif
leonardo1.bmp leonardo2.bmp

Programs to read/write standard image files.

The C program files here all include the compile string in the comments. This makes it very easy to compile any of these files on a Unix system -- just type
grep cc myfile.c | csh

Other Software


CS/ECE 545 Staff
Contents ©1997 - 2011 Norman Wittels and Michael A. Gennert