focus(true); int srcBits= OS.getBitMapForCopyBits(srcImage.pixmap); int maskBits= OS.getBitMapForCopyBits(srcImage.mask); int destBits= OS.GetPortBitMapForCopyBits(handle); if (srcBits != 0 && maskBits != 0 && destBits != 0) { MacRect ib= new MacRect(srcX, srcY, srcWidth, srcHeight); fRect.set(destX, destY, destWidth, destHeight); OS.RGBBackColor(0x00FFFFFF); OS.RGBForeColor(0x00000000); OS.CopyDeepMask(srcBits, maskBits, destBits, ib.getData(), ib.getData(), fRect.getData(), (short)0, 0);
try { if (focus(true, null)) { int srcBits= OS.getBitMapForCopyBits(srcImage.pixmap); int maskBits= OS.getBitMapForCopyBits(srcImage.mask); int destBits= OS.GetPortBitMapForCopyBits(handle); if (srcBits != 0 && maskBits != 0 && destBits != 0) { MacRect ib= new MacRect(srcX, srcY, srcWidth, srcHeight); fRect.set(destX, destY, destWidth, destHeight); OS.RGBBackColor(0x00FFFFFF); OS.RGBForeColor(0x00000000); OS.CopyDeepMask(srcBits, maskBits, destBits, ib.getData(), ib.getData(), fRect.getData(), (short)0, 0); } } } finally { unfocus(true);
void drawImageMask(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, int imgWidth, int imgHeight, int depth) {	/* AW	int xDisplay = data.display;	int xDrawable = data.drawable;	int colorPixmap = srcImage.pixmap;	*/	/* Generate the mask if necessary. */	if (srcImage.transparentPixel != -1) srcImage.createMask();	/* AW	int maskPixmap = srcImage.mask;	int foreground = 0x00000000;	if (!(simple || (srcWidth == destWidth && srcHeight == destHeight))) {	*/		/* Stretch the color and mask*/		/* AW		int xImagePtr = scalePixmap(xDisplay, colorPixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false);		int xMaskPtr = scalePixmap(xDisplay, maskPixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false);		*/				/* Create color scaled pixmaps */		/* AW		colorPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, depth);		int tempGC = OS.XCreateGC(xDisplay, colorPixmap, 0, null);		OS.XPutImage(xDisplay, colorPixmap, tempGC, xImagePtr, 0, 0, 0, 0, destWidth, destHeight);		OS.XDestroyImage(xImagePtr);		OS.XFreeGC(xDisplay, tempGC);		*/		/* Create mask scaled pixmaps */		/* AW		maskPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, 1);		tempGC = OS.XCreateGC(xDisplay, maskPixmap, 0, null);		OS.XPutImage(xDisplay, maskPixmap, tempGC, xMaskPtr, 0, 0, 0, 0, destWidth, destHeight);		OS.XDestroyImage(xMaskPtr);		OS.XFreeGC(xDisplay, tempGC);		*/				/* Change the source rectangle */		/* AW		srcX = srcY = 0;		srcWidth = destWidth;		srcHeight = destHeight;		foreground = ~foreground;		*/	/* AW	}	*/		/* Do the blts */	/* AW	XGCValues values = new XGCValues();	OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS. GCBackground | OS.GCFunction, values);	OS.XSetFunction(xDisplay, handle, OS.GXxor);	OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY);	OS.XSetForeground(xDisplay, handle, foreground);	OS.XSetBackground(xDisplay, handle, ~foreground);	OS.XSetFunction(xDisplay, handle, OS.GXand);	OS.XCopyPlane(xDisplay, maskPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY, 1);	OS.XSetFunction(xDisplay, handle, OS.GXxor);	OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY);	OS.XSetForeground(xDisplay, handle, values.foreground);	OS.XSetBackground(xDisplay, handle, values.background);	OS.XSetFunction(xDisplay, handle, values.function);	*/		// AW	focus(true);	int srcBits= OS.getBitMapForCopyBits(srcImage.pixmap);	int maskBits= OS.getBitMapForCopyBits(srcImage.mask);	int destBits= OS.GetPortBitMapForCopyBits(handle);	if (srcBits != 0 && maskBits != 0 && destBits != 0) {		MacRect ib= new MacRect(srcX, srcY, srcWidth, srcHeight);		fRect.set(destX, destY, destWidth, destHeight);		OS.RGBBackColor(0x00FFFFFF);		OS.RGBForeColor(0x00000000);		OS.CopyDeepMask(srcBits, maskBits, destBits, ib.getData(), ib.getData(), fRect.getData(), (short)0, 0);	}	unfocus(true);	// AW	/* Destroy scaled pixmaps */	/* AW	if (srcImage.pixmap != colorPixmap) OS.XFreePixmap(xDisplay, colorPixmap);	if (srcImage.mask != maskPixmap) OS.XFreePixmap(xDisplay, maskPixmap);	*/	/* Destroy the image mask if the there is a GC created on the image */	if (srcImage.transparentPixel != -1 && srcImage.memGC != null) srcImage.destroyMask();	}