in src/main/java/org/apache/xmlgraphics/image/GraphicsUtil.java [231:302]
public static void copyData_INT_PACK(Raster src, WritableRaster dst) {
// System.out.println("Fast copyData");
int x0 = dst.getMinX();
if (x0 < src.getMinX()) {
x0 = src.getMinX();
}
int y0 = dst.getMinY();
if (y0 < src.getMinY()) {
y0 = src.getMinY();
}
int x1 = dst.getMinX() + dst.getWidth() - 1;
if (x1 > src.getMinX() + src.getWidth() - 1) {
x1 = src.getMinX() + src.getWidth() - 1;
}
int y1 = dst.getMinY() + dst.getHeight() - 1;
if (y1 > src.getMinY() + src.getHeight() - 1) {
y1 = src.getMinY() + src.getHeight() - 1;
}
int width = x1 - x0 + 1;
int height = y1 - y0 + 1;
SinglePixelPackedSampleModel srcSPPSM;
srcSPPSM = (SinglePixelPackedSampleModel)src.getSampleModel();
final int srcScanStride = srcSPPSM.getScanlineStride();
DataBufferInt srcDB = (DataBufferInt)src.getDataBuffer();
final int [] srcPixels = srcDB.getBankData()[0];
final int srcBase =
(srcDB.getOffset()
+ srcSPPSM.getOffset(x0 - src.getSampleModelTranslateX(),
y0 - src.getSampleModelTranslateY()));
SinglePixelPackedSampleModel dstSPPSM;
dstSPPSM = (SinglePixelPackedSampleModel)dst.getSampleModel();
final int dstScanStride = dstSPPSM.getScanlineStride();
DataBufferInt dstDB = (DataBufferInt)dst.getDataBuffer();
final int [] dstPixels = dstDB.getBankData()[0];
final int dstBase =
(dstDB.getOffset()
+ dstSPPSM.getOffset(x0 - dst.getSampleModelTranslateX(),
y0 - dst.getSampleModelTranslateY()));
if ((srcScanStride == dstScanStride)
&& (srcScanStride == width)) {
// System.out.println("VERY Fast copyData");
System.arraycopy(srcPixels, srcBase, dstPixels, dstBase,
width * height);
} else if (width > 128) {
int srcSP = srcBase;
int dstSP = dstBase;
for (int y = 0; y < height; y++) {
System.arraycopy(srcPixels, srcSP, dstPixels, dstSP, width);
srcSP += srcScanStride;
dstSP += dstScanStride;
}
} else {
for (int y = 0; y < height; y++) {
int srcSP = srcBase + y * srcScanStride;
int dstSP = dstBase + y * dstScanStride;
for (int x = 0; x < width; x++) {
dstPixels[dstSP++] = srcPixels[srcSP++];
}
}
}
}