int srcY = source.getMinY();
// Retrieve format tags.
RasterFormatTag[] formatTags = getFormatTags();
RasterAccessor srcAccessor =
new RasterAccessor(source,
new Rectangle(srcX, srcY,
srcWidth, srcHeight),
formatTags[0],
getSourceImage(0).getColorModel());
RasterAccessor dstAccessor =
new RasterAccessor(dest, destRect,
formatTags[1], getColorModel());
// Set data type flags.
int srcDataType = srcAccessor.getDataType();
int dstDataType = dstAccessor.getDataType();
// Set pixel and line strides.
int srcPixelStride = srcAccessor.getPixelStride();
int srcScanlineStride = srcAccessor.getScanlineStride();
int dstPixelStride = dstAccessor.getPixelStride();
int dstScanlineStride = dstAccessor.getScanlineStride();
// Loop over the bands.
int numBands = sampleModel.getNumBands();
for(int band = 0; band < numBands; band++) {
// Get the source and destination arrays for this band.
Object srcData = srcAccessor.getDataArray(band);
Object dstData = dstAccessor.getDataArray(band);
if(destRect.width > 1) {
// Set the FCT length.
fct.setLength(getWidth());
// Initialize the data offsets for this band.
int srcOffset = srcAccessor.getBandOffset(band);
int dstOffset = dstAccessor.getBandOffset(band);
// Perform the row transforms.
for(int row = 0; row < srcHeight; row++) {
// Set the input data of the FCT.
fct.setData(srcDataType, srcData,
srcOffset, srcPixelStride,
srcWidth);
// Calculate the DFT of the row.
fct.transform();
// Get the output data of the FCT.
fct.getData(dstDataType, dstData,
dstOffset, dstPixelStride);
// Increment the data offsets.
srcOffset += srcScanlineStride;
dstOffset += dstScanlineStride;
}
}
if(destRect.width == 1) { // destRect.height > 1
// Initialize the data offsets for this band.
int srcOffset = srcAccessor.getBandOffset(band);
int dstOffset = dstAccessor.getBandOffset(band);
// Set the input data of the FCT.
fct.setData(srcDataType, srcData,
srcOffset, srcScanlineStride,
srcHeight);
// Calculate the DFT of the row.
fct.transform();
// Get the output data of the FCT.
fct.getData(dstDataType, dstData,
dstOffset, dstScanlineStride);
} else if(destRect.height > 1) { // destRect.width > 1
// Reset the FCT length.
fct.setLength(getHeight());
// Initialize destination offset.
int dstOffset = dstAccessor.getBandOffset(band);
// Perform the column transforms.
for(int col = 0; col < destRect.width; col++) {
// Set the input data of the FCT.
fct.setData(dstDataType, dstData,
dstOffset, dstScanlineStride,
destRect.height);
// Calculate the DFT of the column.
fct.transform();
// Get the output data of the FCT.
fct.getData(dstDataType, dstData,
dstOffset, dstScanlineStride);
// Increment the data offset.
dstOffset += dstPixelStride;
}
}
}
if (dstAccessor.needsClamping()) {
dstAccessor.clampDataArrays();
}
// Make sure that the output data is copied to the destination.
dstAccessor.copyDataToRaster();
}