if (xSrcImage.bits_per_pixel == 32) {
if (false && xSrcImage.bits_per_pixel == 32) {
public ImageData getImageData() {	if (isDisposed()) SWT.error(SWT.ERROR_GRAPHIC_DISPOSED);	Rectangle srcBounds = getBounds();	int width = srcBounds.width;	int height = srcBounds.height;	int xDisplay = device.xDisplay;    /* AW	int xSrcImagePtr = OS.XGetImage(xDisplay, pixmap, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);	if (xSrcImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);    */	XImage xSrcImage = new XImage((short)width, (short)height, OS.GetPixDepth(pixmap));    /* AW	OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);    */	/* Calculate the palette depending on the display attributes */	PaletteData palette = null;	/* Get the data for the source image. */	int length = xSrcImage.bytes_per_line * xSrcImage.height;	byte[] srcData = new byte[length];    /* AW	OS.memmove(srcData, xSrcImage.data, length);    */	OS.copyPixmapData(srcData, pixmap, length);		switch (xSrcImage.depth) {		case 1:			palette = new PaletteData(new RGB[] {				new RGB(0, 0, 0),				new RGB(255, 255, 255)			});			break;		case 4:			/*			 * We currently don't run on a 4-bit server, so 4-bit images			 * should not exist.			 */			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);		case 8:			/* Normalize the pixels in the source image data (by making the			 * pixel values sequential starting at pixel 0). Reserve normalized			 * pixel 0 so that it maps to real pixel 0. This assumes pixel 0 is			 * always used in the image.			 */			byte[] normPixel = new byte[ 256 ];			for (int index = 0; index < normPixel.length; index++) {				normPixel[ index ] = 0;			}			int numPixels = 1;			int index = 0;			for (int y = 0; y < xSrcImage.height; y++) {				for (int x = 0; x < xSrcImage.bytes_per_line; x++) {					int srcPixel = srcData[ index + x ] & 0xFF;					if (srcPixel != 0 && normPixel[ srcPixel ] == 0) {						normPixel[ srcPixel ] = (byte)numPixels++;					}					srcData[ index + x ] = normPixel[ srcPixel ];				}				index += xSrcImage.bytes_per_line;			}			/* Create a palette with only the RGB values used in the image. */            /* AW			int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));			*/			RGB[] rgbs = new RGB[ numPixels ];			/* AW			XColor color = new XColor();			*/			for (int srcPixel = 0; srcPixel < normPixel.length; srcPixel++) {				// If the pixel value was used in the image, get its RGB values.				if (srcPixel == 0 || normPixel[ srcPixel ] != 0) {					/*					color.pixel = srcPixel;					OS.XQueryColor(xDisplay, colormap, color);					*/					int packed= OS.getRGB(pixmap, srcPixel);					int rgbIndex = normPixel[ srcPixel ] & 0xFF;					rgbs[ rgbIndex ] = new RGB((packed >> 16) & 0xFF, (packed >> 8) & 0xFF, (packed >> 0) & 0xFF);										/*					rgbs[ rgbIndex ] = new RGB((color.red >> 8) & 0xFF, (color.green >> 8) & 0xFF, (color.blue >> 8) & 0xFF);					*/				}			}						palette = new PaletteData(rgbs);			break;		case 16:			/*			 * For some reason, the XImage does not have the mask information.			 * We must get it from the visual.			 */            /* AW			int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));			Visual v = new Visual();			OS.memmove(v, visual, Visual.sizeof);			palette = new PaletteData(v.red_mask, v.green_mask, v.blue_mask);            */			// AW assumes Mac			palette = new PaletteData(0x7C00, 0x03E0, 0x001F);			break;		case 24:		// AW		case 32:		// AW			/* We always create 24-bit ImageData with the following palette */			/* AW			palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);			*/			// AW assumes Mac			palette = new PaletteData(0xFF0000, 0xFF00, 0xFF);			break;		default:			System.out.println("unsupported depth: " + xSrcImage.depth);			SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);	}	ImageData data = new ImageData(width, height, xSrcImage.depth, palette);	data.data = srcData;	if (xSrcImage.bits_per_pixel == 32) {		/*		 * If bits per pixel is 32, scale the data down to 24, since we do not		 * support 32-bit images		 */		byte[] oldData = data.data;		int bytesPerLine = (xSrcImage.width * xSrcImage.depth + 7) / 8;		bytesPerLine = (bytesPerLine + 3) / 4 * 4;		byte[] newData = new byte[bytesPerLine * xSrcImage.height];		int destIndex = 0;		int srcIndex = 0;		int rOffset = 0, gOffset = 1, bOffset = 2;		if (xSrcImage.byte_order == OS.MSBFirst) {			rOffset = 3; gOffset = 2; bOffset = 1;		}		for (int y = 0; y < height; y++) {			destIndex = y * bytesPerLine;			srcIndex = y * xSrcImage.bytes_per_line;			for (int x = 0; x < width; x++) {				newData[destIndex] = oldData[srcIndex + rOffset];				newData[destIndex + 1] = oldData[srcIndex + gOffset];				newData[destIndex + 2] = oldData[srcIndex + bOffset];				srcIndex += 4;				destIndex += 3;			}		}		data.data = newData;	}	if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {		/* Get the icon data */		data.maskPad = 4;        /* AW		int xMaskPtr = OS.XGetImage(xDisplay, mask, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);		if (xMaskPtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);		*/		XImage xMask = new XImage((short)width, (short)height, OS.GetPixDepth(mask));		/* AW		OS.memmove(xMask, xMaskPtr, XImage.sizeof);		*/		data.maskData = new byte[xMask.bytes_per_line * xMask.height];		/* AW		OS.memmove(data.maskData, xMask.data, data.maskData.length);		OS.XDestroyImage(xMaskPtr);        */		/* Bit swap the mask data if necessary */		if (xMask.bitmap_bit_order == OS.LSBFirst) {			byte[] maskData = data.maskData;			for (int i = 0; i < maskData.length; i++) {				byte b = maskData[i];				maskData[i] = (byte)(((b & 0x01) << 7) | ((b & 0x02) << 5) |					((b & 0x04) << 3) |	((b & 0x08) << 1) | ((b & 0x10) >> 1) |					((b & 0x20) >> 3) |	((b & 0x40) >> 5) | ((b & 0x80) >> 7));			}		}	}	data.transparentPixel = transparentPixel;	data.alpha = alpha;	if (alpha == -1 && alphaData != null) {		data.alphaData = new byte[alphaData.length];		System.arraycopy(alphaData, 0, data.alphaData, 0, alphaData.length);	}    /* AW	OS.XDestroyImage(xSrcImagePtr);    */	return data;}