public void pasteAlphaRect(CPColorBmp bmp, CPRect srcRect, int x, int y) {
		CPRect srcRectCpy = (CPRect) srcRect.clone(), dstRect = new CPRect(x, y, 0, 0);
		getSize().clipSourceDest(srcRectCpy, dstRect);

		int[] srcData = bmp.data;
		for (int j = 0; j < dstRect.bottom - dstRect.top; j++) {
			int srcOffset = srcRectCpy.left + (srcRectCpy.top + j) * bmp.width;
			int dstOffset = dstRect.left + (dstRect.top + j) * width;
			for (int i = dstRect.left; i < dstRect.right; i++, srcOffset++, dstOffset++) {
				int color1 = srcData[srcOffset];
				int alpha1 = color1 >>> 24;

				if (alpha1 <= 0) {
					continue;
				}

				if (alpha1 == 255) {
					data[dstOffset] = color1;
					continue;
				}

				int color2 = data[dstOffset];
				int alpha2 = (color2 >>> 24);

				int newAlpha = alpha1 + alpha2 - alpha1 * alpha2 / 255;
				if (newAlpha > 0) {
					int realAlpha = alpha1 * 255 / newAlpha;
					int invAlpha = 255 - realAlpha;

					data[dstOffset] = newAlpha << 24
							| ((color1 >>> 16 & 0xff) + (((color2 >>> 16 & 0xff) * invAlpha - (color1 >>> 16 & 0xff)
									* invAlpha) / 255)) << 16
							| ((color1 >>> 8 & 0xff) + (((color2 >>> 8 & 0xff) * invAlpha - (color1 >>> 8 & 0xff)
									* invAlpha) / 255)) << 8
							| ((color1 & 0xff) + (((color2 & 0xff) * invAlpha - (color1 & 0xff) * invAlpha) / 255));
				}
			}
		}
	}