void unloadIntoByteStream(ImageData image) {
void unloadIntoByteStream(ImageLoader loader) { ImageData image = loader.data[0];
void unloadIntoByteStream(ImageData image) {	if (!new JPEGStartOfImage().writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	JPEGAppn appn = new JPEGAppn(new byte[] {(byte)0xFF, (byte)0xE0, 0, 0x10, 0x4A, 0x46, 0x49, 0x46, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0});	if (!appn.writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	quantizationTables = new int[4][];	JPEGQuantizationTable chromDQT = JPEGQuantizationTable.defaultChrominanceTable();	chromDQT.scaleBy(encoderQFactor);	int[] jpegDQTKeys = chromDQT.getQuantizationTablesKeys();	int[][] jpegDQTValues = chromDQT.getQuantizationTablesValues();	for (int i = 0; i < jpegDQTKeys.length; i++) {		quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];	}	JPEGQuantizationTable lumDQT = JPEGQuantizationTable.defaultLuminanceTable();	lumDQT.scaleBy(encoderQFactor);	jpegDQTKeys = lumDQT.getQuantizationTablesKeys();	jpegDQTValues = lumDQT.getQuantizationTablesValues();	for (int i = 0; i < jpegDQTKeys.length; i++) {		quantizationTables[jpegDQTKeys[i]] = jpegDQTValues[i];	}	if (!lumDQT.writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	if (!chromDQT.writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	int frameLength, scanLength, precision;	int[][] frameParams, scanParams;	if (image.depth == 1) {		frameLength = 11;		frameParams = new int[1][];		frameParams[0] = new int[] {1, 1, 1, 0, 0};		scanParams = new int[1][];		scanParams[0] = new int[] {0, 0};		scanLength = 8;		nComponents = 1;		precision = 1;	} else {		frameLength = 17;		frameParams = new int[3][];		frameParams[0] = new int[] {0, 2, 2, 0, 0};		frameParams[1] = new int[] {1, 1, 1, 0, 0};		frameParams[2] = new int[] {1, 1, 1, 0, 0};		scanParams = new int[3][];		scanParams[0] = new int[] {0, 0};		scanParams[1] = new int[] {1, 1};		scanParams[2] = new int[] {1, 1};		scanLength = 12;		nComponents = 3;		precision = 8;	}	imageWidth = image.width;	imageHeight = image.height;	frameHeader = new JPEGFrameHeader(new byte[19]);	frameHeader.setSegmentMarker(SOF0);	frameHeader.setSegmentLength(frameLength);	frameHeader.setSamplePrecision(precision);	frameHeader.setSamplesPerLine(imageWidth);	frameHeader.setNumberOfLines(imageHeight);	frameHeader.setNumberOfImageComponents(nComponents);	frameHeader.componentParameters = frameParams;	frameHeader.componentIdentifiers = new int[] {0, 1, 2};	frameHeader.initializeContents();	if (!frameHeader.writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	frameComponents = frameParams;	componentIds = frameHeader.componentIdentifiers;	maxH = frameHeader.getMaxHFactor();	maxV = frameHeader.getMaxVFactor();	int mcuWidth = maxH * DCTSIZE;	int mcuHeight = maxV * DCTSIZE;	interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;	interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;	acHuffmanTables = new JPEGHuffmanTable[4];	dcHuffmanTables = new JPEGHuffmanTable[4];	JPEGHuffmanTable[] dhtTables = new JPEGHuffmanTable[] {		JPEGHuffmanTable.getDefaultDCLuminanceTable(),		JPEGHuffmanTable.getDefaultDCChrominanceTable(),		JPEGHuffmanTable.getDefaultACLuminanceTable(),		JPEGHuffmanTable.getDefaultACChrominanceTable()	};	for (int i = 0; i < dhtTables.length; i++) {		JPEGHuffmanTable dhtTable = dhtTables[i];		if (!dhtTable.writeToStream(outputStream)) {			SWT.error(SWT.ERROR_IO);		}		JPEGHuffmanTable[] allTables = dhtTable.getAllTables();		for (int j = 0; j < allTables.length; j++) {			JPEGHuffmanTable huffmanTable = allTables[j];			if (huffmanTable.getTableClass() == 0) {				dcHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;			} else {				acHuffmanTables[huffmanTable.getTableIdentifier()] = huffmanTable;			}		}	}	precedingDCs = new int[4];	scanHeader = new JPEGScanHeader(new byte[14]);	scanHeader.setSegmentMarker(SOS);	scanHeader.setSegmentLength(scanLength);	scanHeader.setNumberOfImageComponents(nComponents);	scanHeader.setStartOfSpectralSelection(0);	scanHeader.setEndOfSpectralSelection(63);	scanHeader.componentParameters = scanParams;	scanHeader.initializeContents();	if (!scanHeader.writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}	convertImageToYCbCr(image);	resetOutputBuffer();	currentByte = 0;	currentBitCount = 0;	encodeScan();	if (!new JPEGEndOfImage().writeToStream(outputStream)) {		SWT.error(SWT.ERROR_IO);	}}