!dataNature.equals(DFTDescriptor.REAL_TO_COMPLEX);
boolean isComplexDest =
!dataNature.equals(DFTDescriptor.COMPLEX_TO_REAL);
// Get the number of source bands.
SampleModel srcSampleModel = source.getSampleModel();
int numSourceBands = srcSampleModel.getNumBands();
// Check for mediaLib support of this source.
if((isComplexSource && numSourceBands != 2) ||
(!isComplexSource && numSourceBands != 1)) {
// This should never occur due to checks in
// MlibDFTRIF and MlibIDFTRIF.
throw new RuntimeException(JaiI18N.getString("MlibDFTOpImage0"));
}
// Create an ImageLayout or clone the one passed in.
ImageLayout il = layout == null ?
new ImageLayout() : (ImageLayout)layout.clone();
// Force the origin to coincide with that of the source.
il.setMinX(source.getMinX());
il.setMinY(source.getMinY());
// Recalculate the non-unity dimensions to be a positive power of 2.
// XXX This calculation should not be effected if an implementation
// of the FFT which supports arbitrary dimensions is used.
int currentWidth = il.getWidth(source);
int currentHeight = il.getHeight(source);
int newWidth;
int newHeight;
if(currentWidth == 1 && currentHeight == 1) {
newWidth = newHeight = 1;
} else if(currentWidth == 1 && currentHeight > 1) {
newWidth = 1;
newHeight = MathJAI.nextPositivePowerOf2(currentHeight);
} else if(currentWidth > 1 && currentHeight == 1) {
newWidth = MathJAI.nextPositivePowerOf2(currentWidth);
newHeight = 1;
} else { // Neither dimension equal to unity.
newWidth = MathJAI.nextPositivePowerOf2(currentWidth);
newHeight = MathJAI.nextPositivePowerOf2(currentHeight);
}
il.setWidth(newWidth);
il.setHeight(newHeight);
// Initialize the SampleModel creation flag.
boolean createNewSampleModel = false;
// Determine the number of required bands.
int requiredNumBands = numSourceBands;
if(isComplexSource && !isComplexDest) {
requiredNumBands /= 2;
} else if(!isComplexSource && isComplexDest) {
requiredNumBands *= 2;
}
// Set the number of bands.
SampleModel sm = il.getSampleModel(source);
int numBands = sm.getNumBands();
if(numBands != requiredNumBands) {
numBands = requiredNumBands;
createNewSampleModel = true;
}
// Force the image to contain floating point data.
int dataType = sm.getTransferType();
if(dataType != DataBuffer.TYPE_FLOAT &&
dataType != DataBuffer.TYPE_DOUBLE) {
dataType = DataBuffer.TYPE_FLOAT;
createNewSampleModel = true;
}