"inputData");
throw new IllegalArgumentException(msg);
}
CollectionImage input = null;
CollectionImage translated = new GenericCollectionImage();
try {
for (InputImageConditioner c : conditioners) {
inputData = c.process(inputData);
}
input = (CollectionImage)
ImageReadDescriptor.createCollection(
inputData,
null,
Boolean.TRUE,
Boolean.FALSE,
Boolean.FALSE,
null,
null,
null,
null,
null);
Iterator it = input.iterator();
while(it.hasNext()) {
int minX = 0;
int minY = 0;
RenderedOp op = (RenderedOp) it.next();
// for some reason this method occasinally returns an Object
// i.e. not an IIOMetadata instance
Object imageMetaObj = op.getProperty("JAI.ImageMetadata");
if (imageMetaObj instanceof IIOMetadata) {
IIOMetadata imageMeta = (IIOMetadata) imageMetaObj;
if (imageMeta != null && imageMeta.isStandardMetadataFormatSupported()) {
Node root = imageMeta.getAsTree("javax_imageio_1.0");
Node dimension = getChildByLocalName(root, "Dimension");
Node minXNode = null;
Node minYNode = null;
if (dimension != null) {
minXNode = getChildByLocalName(
dimension, "HorizontalPixelOffset");
minYNode = getChildByLocalName(
dimension, "VerticalPixelOffset");
}
if (minXNode != null) {
minX = Integer.parseInt(minXNode.
getAttributes().getNamedItem("value").getNodeValue());
}
if (minYNode != null) {
minY = Integer.parseInt(minYNode.
getAttributes().getNamedItem("value").getNodeValue());
}
}
}
if (minX != 0 || minY != 0) {
translated.add(TranslateDescriptor.create(op, (float) minX, (float) minY, null, null));
} else {
translated.add(op);
}
}
} catch (Exception e) {
LOGGER.error("jai-operation-failure", new String[]{ "ImageRead", e.toString() });
throw new RuntimeException(e);
}
final RenderedOp[] result = new RenderedOp[input.size()];
int i = 0;
for (Iterator iter = translated.iterator(); iter.hasNext(); i++) {
RenderedOp op = (RenderedOp) iter.next();
final int dataType = op.getSampleModel().getDataType();
if (dataType != DataBuffer.TYPE_BYTE) {
op = changeDataTypeToByte(op);
}