private void writeBitmap() throws Exception {
	int	size;
	int	value;
	int	j;
	int	i;
	int	rowCount;
	int	rowIndex;
	int	lastRowIndex;
	int	pad;
	int	padCount;
	byte	rgb[]	= new byte[3];

	size	= (biWidth * biHeight) - 1;
	pad	= 4 - ((biWidth * 3) % 4);

	// The following bug correction will cause the bitmap to be unreadable by
	// GIMP.  It must be there for the bitmap to be readable by most other
	// graphics packages.
	if (pad == 4) {		// <==== Bug correction
	    pad	= 0;
	}			// <==== Bug correction

	rowCount	= 1;
	padCount	= 0;
	rowIndex	= size - biWidth;
	lastRowIndex	= rowIndex;

	// try {
	// The following three lines of code are a correction supplied
	// by Alin Arsu, Feb 2003.  The original code set the top-right
	// pixel in the image to black, and also shifted the bottom row
	// of the image by one pixel.
	// The original code was the following two lines:
	// for (j = 0; j < size; j++) {
	// value = bitmap [rowIndex];
	// This is replaced by the three lines that appear next.
	for (j = 0; j < size + 1; j++) {
	    if (j < biWidth) {
		value	= bitmap[rowIndex + 1];
	    } else {
		value	= bitmap[rowIndex];
	    }

	    rgb[0]	= (byte) (value & 0xFF);
	    rgb[1]	= (byte) ((value >> 8) & 0xFF);
	    rgb[2]	= (byte) ((value >> 16) & 0xFF);
	    fo.write(rgb);

	    if (rowCount == biWidth) {
		padCount	+= pad;

		for (i = 1; i <= pad; i++) {
		    fo.write(0x00);
		}

		rowCount	= 1;
		rowIndex	= lastRowIndex - biWidth;
		lastRowIndex	= rowIndex;
	    } else {
		rowCount++;
	    }

	    rowIndex++;
	}

	// --- Update the size of the file
	bfSize		+= padCount - pad;
	biSizeImage	+= padCount - pad;

	/*
	 * }
	 * catch (Exception wb) {
	 *   wb.printStackTrace ();
	 * }
	 */
    }