private void smudgePasteBuffer(CPRect srcRect, CPRect dstRect, int[] buffer, byte[] brush, int w, int alpha) {
			int[] undoData = undoBuffer.data;

			int by = srcRect.top;
			for (int j = dstRect.top; j < dstRect.bottom; j++, by++) {
				int srcOffset = srcRect.left + by * w;
				int dstOffset = dstRect.left + j * width;
				for (int i = dstRect.left; i < dstRect.right; i++, srcOffset++, dstOffset++) {
					int bufferColor = buffer[srcOffset];
					int opacityAlpha = (bufferColor >>> 24) * (brush[srcOffset] & 0xff) / 255;
					if (opacityAlpha > 0) {
						int destColor = undoData[dstOffset];

						int realAlpha = 255;
						int invAlpha = 255 - realAlpha;

						int newColor = (((bufferColor >>> 24 & 0xff) * realAlpha + (destColor >>> 24 & 0xff) * invAlpha) / 255) << 24
								& 0xff000000
								| (((bufferColor >>> 16 & 0xff) * realAlpha + (destColor >>> 16 & 0xff) * invAlpha) / 255) << 16
								& 0xff0000
								| (((bufferColor >>> 8 & 0xff) * realAlpha + (destColor >>> 8 & 0xff) * invAlpha) / 255) << 8
								& 0xff00
								| (((bufferColor & 0xff) * realAlpha + (destColor & 0xff) * invAlpha) / 255)
								& 0xff;

						curLayer.data[dstOffset] = newColor;
					}
				}
			}
		}