Rectangle destRect) {
// Retrieve format tags.
RasterFormatTag[] formatTags = getFormatTags();
/* For PointOpImage, srcRect = destRect. */
RasterAccessor s1 = new RasterAccessor(sources[0], destRect,
formatTags[0],
getSourceImage(0).getColorModel());
RasterAccessor s2 = new RasterAccessor(sources[1], destRect,
formatTags[1],
getSourceImage(1).getColorModel());
RasterAccessor d = new RasterAccessor(dest, destRect,
formatTags[2], getColorModel());
if(d.isBinary()) {
byte[] dstBits = d.getBinaryDataArray();
// Subtraction in this case boils down to copying image 1.
System.arraycopy(s1.getBinaryDataArray(), 0,
dstBits, 0, dstBits.length);
d.copyBinaryDataToRaster();
return;
}
int src1LineStride = s1.getScanlineStride();
int src1PixelStride = s1.getPixelStride();
int[] src1BandOffsets = s1.getBandOffsets();
int src2LineStride = s2.getScanlineStride();
int src2PixelStride = s2.getPixelStride();
int[] src2BandOffsets = s2.getBandOffsets();
int dstNumBands = d.getNumBands();
int dstWidth = d.getWidth();
int dstHeight = d.getHeight();
int dstLineStride = d.getScanlineStride();
int dstPixelStride = d.getPixelStride();
int[] dstBandOffsets = d.getBandOffsets();
switch (d.getDataType()) {
case DataBuffer.TYPE_BYTE:
byteLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getByteDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getByteDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getByteDataArrays());
break;
case DataBuffer.TYPE_USHORT:
ushortLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getShortDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getShortDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getShortDataArrays());
break;
case DataBuffer.TYPE_SHORT:
shortLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getShortDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getShortDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getShortDataArrays());
break;
case DataBuffer.TYPE_INT:
intLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getIntDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getIntDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getIntDataArrays());
break;
case DataBuffer.TYPE_FLOAT:
floatLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getFloatDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getFloatDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getFloatDataArrays());
break;
case DataBuffer.TYPE_DOUBLE:
doubleLoop(dstNumBands, dstWidth, dstHeight,
src1LineStride, src1PixelStride,
src1BandOffsets, s1.getDoubleDataArrays(),
src2LineStride, src2PixelStride,
src2BandOffsets, s2.getDoubleDataArrays(),
dstLineStride, dstPixelStride,
dstBandOffsets, d.getDoubleDataArrays());
break;
}
if (d.needsClamping()) {
d.clampDataArrays();
}
d.copyDataToRaster();
}