void unloadIntoByteStream(ImageData image) {
void unloadIntoByteStream(ImageLoader loader) { ImageData image = loader.data[0];
void unloadIntoByteStream(ImageData image) {	byte[] rgbs;	int numCols;	if (!((image.depth == 1) || (image.depth == 4) || (image.depth == 8) ||		  (image.depth == 16) || (image.depth == 24) || (image.depth == 32)))			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);	PaletteData pal = image.palette;	if ((image.depth == 16) || (image.depth == 24) || (image.depth == 32)) {		if (!pal.isDirect)			SWT.error(SWT.ERROR_INVALID_IMAGE);		numCols = 0;		rgbs = null;	} else {		if (pal.isDirect)			SWT.error(SWT.ERROR_INVALID_IMAGE);		numCols = pal.colors.length;		rgbs = paletteToBytes(pal);	}	// Fill in file header, except for bfsize, which is done later.	int headersSize = BMPFileHeaderSize + BMPHeaderFixedSize;	int[] fileHeader = new int[5];	fileHeader[0] = 0x4D42;	// Signature	fileHeader[1] = 0; // File size - filled in later	fileHeader[2] = 0; // Reserved 1	fileHeader[3] = 0; // Reserved 2	fileHeader[4] = headersSize; // Offset to data	if (rgbs != null) {		fileHeader[4] += rgbs.length;	}	// Prepare data. This is done first so we don't have to try to rewind	// the stream and fill in the details later.	ByteArrayOutputStream out = new ByteArrayOutputStream();	unloadData(image, out);	byte[] data = out.toByteArray();		// Calculate file size	fileHeader[1] = fileHeader[4] + data.length;	// Write the headers	try {		outputStream.writeShort(fileHeader[0]);		outputStream.writeInt(fileHeader[1]);		outputStream.writeShort(fileHeader[2]);		outputStream.writeShort(fileHeader[3]);		outputStream.writeInt(fileHeader[4]);	} catch (IOException e) {		SWT.error(SWT.ERROR_IO, e);	}	try {		outputStream.writeInt(BMPHeaderFixedSize);		outputStream.writeShort(image.width);		outputStream.writeShort(image.height);		outputStream.writeShort(1);		outputStream.writeShort((short)image.depth);	} catch (IOException e) {		SWT.error(SWT.ERROR_IO, e);	}		// Unload palette	if (numCols > 0) {		try {			outputStream.write(rgbs);		} catch (IOException e) {			SWT.error(SWT.ERROR_IO, e);		}	}	// Unload the data	try {		outputStream.write(data);	} catch (IOException e) {		SWT.error(SWT.ERROR_IO, e);	}}