public WritableRaster copyData(WritableRaster wr) { // Get my source. CachableRed src = (CachableRed) getSources().get(0); Rectangle r = wr.getBounds(); r.x -= xinset; r.y -= yinset; r.width += 2 * xinset; r.height += 2 * yinset; // System.out.println("Gaussian GenR: " + wr); // System.out.println("SrcReq: " + r); ColorModel srcCM = src.getColorModel(); WritableRaster tmpR1 = null, tmpR2 = null; tmpR1 = srcCM.createCompatibleWritableRaster(r.width, r.height); { WritableRaster fill; fill = tmpR1.createWritableTranslatedChild(r.x, r.y); src.copyData(fill); } if (srcCM.hasAlpha() && !srcCM.isAlphaPremultiplied()) GraphicsUtil.coerceData(tmpR1, srcCM, true); // For the blur box approx we can use dest as our intermediate // otherwise we let it default to null which means we create a new // one... // this lets the Vertical conv know how much is junk, so it // doesn't bother to convolve the top and bottom edges int skipX; // long t1 = System.currentTimeMillis(); if (xinset == 0) { skipX = 0; } else if (convOp[0] != null) { tmpR2 = getColorModel().createCompatibleWritableRaster(r.width, r.height); tmpR2 = convOp[0].filter(tmpR1, tmpR2); skipX = convOp[0].getKernel().getXOrigin(); // Swap them... WritableRaster tmp = tmpR1; tmpR1 = tmpR2; tmpR2 = tmp; } else { if ((dX & 0x01) == 0) { tmpR1 = boxFilterH(tmpR1, tmpR1, 0, 0, dX, dX / 2); tmpR1 = boxFilterH(tmpR1, tmpR1, dX / 2, 0, dX, dX / 2 - 1); tmpR1 = boxFilterH(tmpR1, tmpR1, dX - 1, 0, dX + 1, dX / 2); skipX = dX - 1 + dX / 2; } else { tmpR1 = boxFilterH(tmpR1, tmpR1, 0, 0, dX, dX / 2); tmpR1 = boxFilterH(tmpR1, tmpR1, dX / 2, 0, dX, dX / 2); tmpR1 = boxFilterH(tmpR1, tmpR1, dX - 2, 0, dX, dX / 2); skipX = dX - 2 + dX / 2; } } if (yinset == 0) { tmpR2 = tmpR1; } else if (convOp[1] != null) { if (tmpR2 == null) { tmpR2 = getColorModel().createCompatibleWritableRaster(r.width, r.height); } tmpR2 = convOp[1].filter(tmpR1, tmpR2); } else { if ((dY & 0x01) == 0) { tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, 0, dY, dY / 2); tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY / 2, dY, dY / 2 - 1); tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY - 1, dY + 1, dY / 2); } else { tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, 0, dY, dY / 2); tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY / 2, dY, dY / 2); tmpR1 = boxFilterV(tmpR1, tmpR1, skipX, dY - 2, dY, dY / 2); } tmpR2 = tmpR1; } // long t2 = System.currentTimeMillis(); // System.out.println("Time: " + (t2-t1) + // (((convOp[0] != null) || (convOp[1] != null))? // " ConvOp":"")); // System.out.println("Rasters WR :" + wr.getBounds()); // System.out.println(" tmp:" + tmpR2.getBounds()); // System.out.println(" bounds:" + getBounds()); // System.out.println(" skipX:" + skipX + // " dx:" + dX + " Dy: " + dY); tmpR2 = tmpR2.createWritableTranslatedChild(r.x, r.y); GraphicsUtil.copyData(tmpR2, wr); return wr; }