Raster source = sources[0];
// Get the source rectangle
Rectangle srcRect = source.getBounds();
RasterAccessor srcAccessor =
new RasterAccessor(source, srcRect,
formatTags[0], getSource(0).getColorModel());
RasterAccessor dstAccessor =
new RasterAccessor(dest, destRect, formatTags[1], getColorModel());
int dwidth = destRect.width;
int dheight = destRect.height;
int srcPixelStride = srcAccessor.getPixelStride();
int srcScanlineStride = srcAccessor.getScanlineStride();
int[] ypos = new int[dheight];
int[] xpos = new int[dwidth];
int xfracvalues[] = null, yfracvalues[] = null;
float xfracvaluesFloat[] = null, yfracvaluesFloat[] = null;
switch (dstAccessor.getDataType()) {
case DataBuffer.TYPE_BYTE:
case DataBuffer.TYPE_SHORT:
case DataBuffer.TYPE_USHORT:
case DataBuffer.TYPE_INT:
yfracvalues = new int[dheight];
xfracvalues = new int[dwidth];
preComputePositionsInt(destRect, srcRect.x, srcRect.y,
srcPixelStride, srcScanlineStride,
xpos, ypos, xfracvalues, yfracvalues);
break;
case DataBuffer.TYPE_FLOAT:
case DataBuffer.TYPE_DOUBLE:
yfracvaluesFloat = new float[dheight];
xfracvaluesFloat = new float[dwidth];
preComputePositionsFloat(destRect, srcRect.x, srcRect.y,
srcPixelStride, srcScanlineStride,
xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
break;
default:
throw
new RuntimeException(JaiI18N.getString("OrderedDitherOpImage0"));
}
switch (dstAccessor.getDataType()) {
case DataBuffer.TYPE_BYTE:
byteLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvalues, yfracvalues);
break;
case DataBuffer.TYPE_SHORT:
shortLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvalues, yfracvalues);
break;
case DataBuffer.TYPE_USHORT:
ushortLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvalues, yfracvalues);
break;
case DataBuffer.TYPE_INT:
intLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvalues, yfracvalues);
break;
case DataBuffer.TYPE_FLOAT:
floatLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
break;
case DataBuffer.TYPE_DOUBLE:
doubleLoop(srcAccessor, destRect, dstAccessor,
xpos, ypos, xfracvaluesFloat, yfracvaluesFloat);
break;
}
// If the RasterAccessor object set up a temporary buffer for the
// op to write to, tell the RasterAccessor to write that data
// to the raster no that we're done with it.
if (dstAccessor.isDataCopy()) {
dstAccessor.clampDataArrays();
dstAccessor.copyDataToRaster();
}
}