RenderedImage source = paramBlock.getRenderedSource(0);
ImageLayout layout = renderHints == null ? null :
(ImageLayout)renderHints.get(JAI.KEY_IMAGE_LAYOUT);
ColorQuantizerType algorithm =
(ColorQuantizerType)paramBlock.getObjectParameter(0);
int maxColorNum = paramBlock.getIntParameter(1);
int upperBound = paramBlock.getIntParameter(2);
ROI roi= (ROI)paramBlock.getObjectParameter(3);
int xPeriod = paramBlock.getIntParameter(4);
int yPeriod = paramBlock.getIntParameter(5);
// check if 3-band byte-type image
SampleModel sm = source.getSampleModel();
if (sm.getNumBands() != 3 && sm.getDataType() == DataBuffer.TYPE_BYTE)
throw new IllegalArgumentException("ColorQuantizerRIF0");
if (algorithm.equals(ColorQuantizerDescriptor.NEUQUANT))
return new NeuQuantOpImage(source, (Map)renderHints, layout,
maxColorNum, upperBound, roi,
xPeriod, yPeriod);
if (algorithm.equals(ColorQuantizerDescriptor.OCTTREE))
return new OctTreeOpImage(source, (Map)renderHints, layout,
maxColorNum, upperBound, roi,
xPeriod, yPeriod);
else
return new MedianCutOpImage(source, (Map)renderHints, layout,