private void transformedBlit(ColorModel srcCM, Raster srcR, int srcX, int srcY,
ColorModel dstCM, WritableRaster dstR, int dstX, int dstY,
int width, int height, AffineTransform at, Composite comp,
Color bgcolor,MultiRectArea clip) {
Rectangle srcBounds = new Rectangle(srcX, srcY, width, height);
Rectangle dstBlitBounds = new Rectangle(dstX, dstY, width, height);
Rectangle transSrcBounds = getBounds2D(at, srcBounds).getBounds();
Rectangle transDstBlitBounds = getBounds2D(at, dstBlitBounds).getBounds();
int translateX = transDstBlitBounds.x - transSrcBounds.x;
int translateY = transDstBlitBounds.y - transSrcBounds.y;
AffineTransform inv = null;
try {
inv = at.createInverse();
} catch (NoninvertibleTransformException e) {
return;
}
double[] m = new double[6];
inv.getMatrix(m);
int clipRects[];
if(clip != null) {
clipRects = clip.rect;
} else {
clipRects = new int[]{5, 0, 0, dstR.getWidth(), dstR.getHeight()};
}
int compType = 0;
int srcConstAlpha = 0;
int rule = 0;
int bgRGB = bgcolor == null ? 0 : bgcolor.getRGB();
int srcRGB = 0, dstRGB = 0;
Object srcVal = null, dstVal = null;
if(comp instanceof AlphaComposite){
compType = AlphaCompositeMode;
AlphaComposite ac = (AlphaComposite) comp;
rule = ac.getRule();
srcConstAlpha = (int)(ac.getAlpha() * 255 + 0.5f);
}else if(comp instanceof XORComposite){
compType = XORMode;
XORComposite xor = (XORComposite) comp;
bgRGB = xor.getXORColor().getRGB();
}
for(int i = 1; i < clipRects[0]; i += 4){
Rectangle dstBounds = new Rectangle(clipRects[i], clipRects[i + 1], 0, 0);
dstBounds.add(clipRects[i + 2] + 1, clipRects[i + 1]);
dstBounds.add(clipRects[i + 2] + 1, clipRects[i + 3] + 1);
dstBounds.add(clipRects[i], clipRects[i + 3] + 1);
Rectangle bounds = dstBounds.intersection(transDstBlitBounds);
int minSrcX = srcBounds.x;
int minSrcY = srcBounds.y;
int maxSrcX = minSrcX + srcBounds.width;
int maxSrcY = minSrcY + srcBounds.height;