// set the OpImage's SM to be MultiPixelPackedSampleModel
private static ImageLayout layoutHelper(RenderedImage source,
ImageLayout il,
Map config) {
ImageLayout layout = (il == null) ?
new ImageLayout() : (ImageLayout)il.clone();
SampleModel sm = layout.getSampleModel(source);
if(!ImageUtil.isBinary(sm)) {
sm = new MultiPixelPackedSampleModel(DataBuffer.TYPE_BYTE,
layout.getTileWidth(source),
layout.getTileHeight(source),
1);
layout.setSampleModel(sm);
}
ColorModel cm = layout.getColorModel(null);
if(cm == null ||
!JDKWorkarounds.areCompatibleDataModels(sm, cm)) {
layout.setColorModel(ImageUtil.getCompatibleColorModel(sm,
config));
}
return layout;
}