destRedMask = getRedMask(screenDepth); destGreenMask = getGreenMask(screenDepth); destBlueMask = getBlueMask(screenDepth);
destRedMask = getRedMask(destDepth); destGreenMask = getGreenMask(destDepth); destBlueMask = getBlueMask(destDepth);
static int putImage(ImageData image, int screenDepth, int[] transparentPixel, int drawable) {		int srcX= 0, srcY= 0;	int srcWidth= image.width, srcHeight= image.height;	int destX= srcX, destY= srcY, destWidth= srcWidth, destHeight= srcHeight;				PaletteData palette = image.palette;	if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||		((image.depth == 8) || (image.depth == 16 || image.depth == 24 || image.depth == 32) && palette.isDirect)))			return SWT.ERROR_UNSUPPORTED_DEPTH;				boolean flipX = destWidth < 0;	boolean flipY = destHeight < 0;	if (flipX) {		destWidth = -destWidth;		destX = destX - destWidth;	}	if (flipY) {		destHeight = -destHeight;		destY = destY - destHeight;	}		byte[] srcReds = null, srcGreens = null, srcBlues = null;	if (!palette.isDirect) {		RGB[] rgbs = palette.getRGBs();		int length = rgbs.length;		srcReds = new byte[length];		srcGreens = new byte[length];		srcBlues = new byte[length];		for (int i = 0; i < rgbs.length; i++) {			RGB rgb = rgbs[i];			if (rgb == null) continue;			srcReds[i] = (byte)rgb.red;			srcGreens[i] = (byte)rgb.green;			srcBlues[i] = (byte)rgb.blue;		}	}		byte[] destReds = null, destGreens = null, destBlues = null;	int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;	final boolean screenDirect;	if (screenDepth <= 8) {		destReds = new byte[srcReds.length];		destGreens = new byte[srcGreens.length];		destBlues = new byte[srcBlues.length];		for (int i = 0; i < srcReds.length; i++) {			destReds[i] = srcReds[i];			destGreens[i] = srcGreens[i];			destBlues[i] = srcBlues[i];		}		setColorTable(drawable, destReds, destGreens, destBlues);		screenDirect = false;	} else {		destRedMask = getRedMask(screenDepth);		destGreenMask = getGreenMask(screenDepth);		destBlueMask = getBlueMask(screenDepth);		screenDirect = true;	}	if (transparentPixel != null) {		int transRed = 0, transGreen = 0, transBlue = 0;		if (palette.isDirect) {			RGB rgb = palette.getRGB(transparentPixel[0]);			transRed = rgb.red;			transGreen = rgb.green;			transBlue = rgb.blue;		} else {			RGB[] rgbs = palette.getRGBs();			if (transparentPixel[0] < rgbs.length) {				RGB rgb = rgbs[transparentPixel[0]];				transRed = rgb.red;				transGreen = rgb.green;				transBlue = rgb.blue;			}		}		transparentPixel[0] = ImageData.closestMatch(screenDepth, (byte)transRed, (byte)transGreen, (byte)transBlue,			destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);	}		int destDepth= screenDepth; // Device.getDeviceDepth(OS.GetMainDevice());	int destBitsPerPixel= destDepth;		int dest_red_mask= getRedMask(destBitsPerPixel);	int dest_green_mask= getGreenMask(destBitsPerPixel);	int dest_blue_mask= getBlueMask(destBitsPerPixel);		int destRowBytes= rowBytes(destWidth, destDepth);	int bufSize = destRowBytes * destHeight;		byte[] buf = new byte[bufSize];	int srcOrder = image.getByteOrder();		if (palette.isDirect) {		if (screenDirect) {			ImageData.blit(ImageData.BLIT_SRC,				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,				ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY, 				buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, dest_red_mask, dest_green_mask, dest_blue_mask,				flipX, flipY);		} else {			ImageData.blit(ImageData.BLIT_SRC,				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask,				ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,				buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,				flipX, flipY);		}	} else {		if (screenDirect) {			ImageData.blit(ImageData.BLIT_SRC,				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,				ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,				buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, dest_red_mask, dest_green_mask, dest_blue_mask,				flipX, flipY);		} else {			ImageData.blit(ImageData.BLIT_SRC,				image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues,				ImageData.ALPHA_OPAQUE, null, 0, srcX, srcY,				buf, destBitsPerPixel, destRowBytes, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,				flipX, flipY);		}	}	setPixMapData(drawable, buf);	return 0;}