if (!wantRaster){
// Can we read this image?
Iterator imageTypes = getImageTypes(imageIndex);
if (imageTypes.hasNext() == false) {
throw new IIOException("Unsupported Image Type");
}
image = getDestination(param, imageTypes, width, height);
imRas = image.getRaster();
// The destination may still be incompatible.
numImageBands = image.getSampleModel().getNumBands();
// Check whether we can handle any implied color conversion
// Throws IIOException if the stream and the image are
// incompatible, and sets convert if a java conversion
// is necessary
checkColorConversion(image, param);
// Check the source and destination bands in the param
checkReadParamBandSettings(param, numComponents, numImageBands);
} else {
// Set the output color space equal to the input colorspace
// This disables all conversions
setOutColorSpace(structPointer, colorSpaceCode);
image = null;
}
// Create an intermediate 1-line Raster that will hold the decoded,
// subsampled, clipped, band-selected image data in a single
// byte-interleaved buffer. The above transformations
// will occur in C for performance. Every time this Raster
// is filled we will call back to acceptPixels below to copy
// this to whatever kind of buffer our image has.
int [] srcBands = JPEG.bandOffsets[numComponents-1];
int numRasterBands = (wantRaster ? numComponents : numImageBands);
destinationBands = null;
Rectangle srcROI = new Rectangle(0, 0, 0, 0);
destROI = new Rectangle(0, 0, 0, 0);
computeRegions(param, width, height, image, srcROI, destROI);
int periodX = 1;
int periodY = 1;
minProgressivePass = 0;
maxProgressivePass = Integer.MAX_VALUE;
if (param != null) {
periodX = param.getSourceXSubsampling();
periodY = param.getSourceYSubsampling();
int[] sBands = param.getSourceBands();
if (sBands != null) {
srcBands = sBands;
numRasterBands = srcBands.length;
}
if (!wantRaster) { // ignore dest bands for Raster
destinationBands = param.getDestinationBands();
}
minProgressivePass = param.getSourceMinProgressivePass();
maxProgressivePass = param.getSourceMaxProgressivePass();
if (param instanceof JPEGImageReadParam) {
JPEGImageReadParam jparam = (JPEGImageReadParam) param;
if (jparam.areTablesSet()) {
abbrevQTables = jparam.getQTables();
abbrevDCHuffmanTables = jparam.getDCHuffmanTables();
abbrevACHuffmanTables = jparam.getACHuffmanTables();
}
}
}
int lineSize = destROI.width*numRasterBands;
buffer = new DataBufferByte(lineSize);
int [] bandOffs = JPEG.bandOffsets[numRasterBands-1];
raster = Raster.createInterleavedRaster(buffer,
destROI.width, 1,
lineSize,
numRasterBands,
bandOffs,
null);
// Now that we have the Raster we'll decode to, get a view of the
// target Raster that will permit a simple setRect for each scanline
if (wantRaster) {
target = Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
destROI.width,
destROI.height,
lineSize,
numRasterBands,
bandOffs,
null);
} else {
target = imRas;
}
int [] bandSizes = target.getSampleModel().getSampleSize();
for (int i = 0; i < bandSizes.length; i++) {
if (bandSizes[i] <= 0 || bandSizes[i] > 8) {
throw new IIOException("Illegal band size: should be 0 < size <= 8");
}
}
/*
* If the process is sequential, and we have restart markers,