public static ROIScaler createInstance(Quantizer src, ParameterList pl, EncoderSpecs encSpec)
{
System.Collections.Generic.List<ROI> roiVector = new List<ROI>(10);
ROIMaskGenerator maskGen = null;
// Check parameters
pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
// Get parameters and check if there are and ROIs specified
System.String roiopt = pl.getParameter("Rroi");
if (roiopt == null)
{
// No ROIs specified! Create ROIScaler with no mask generator
return new ROIScaler(src, null, false, - 1, false, encSpec);
}
// Check if the lowest resolution levels should belong to the ROI
int sLev = pl.getIntParameter("Rstart_level");
// Check if the ROIs are block-aligned
bool useBlockAligned = pl.getBooleanParameter("Ralign");
// Check if generic mask generation is specified
bool onlyRect = !pl.getBooleanParameter("Rno_rect");
// Parse the ROIs
parseROIs(roiopt, src.NumComps, roiVector);
ROI[] roiArray = new ROI[roiVector.Count];
roiVector.CopyTo(roiArray);
// If onlyRect has been forced, check if there are any non-rectangular
// ROIs specified. Currently, only the presence of circular ROIs will
// make this false
if (onlyRect)
{
for (int i = roiArray.Length - 1; i >= 0; i--)
if (!roiArray[i].rect)
{
onlyRect = false;
break;
}
}
if (onlyRect)
{
// It's possible to use the fast ROI mask generation when only
// rectangular ROIs are specified.
maskGen = new RectROIMaskGenerator(roiArray, src.NumComps);
}
else
{
// It's necessary to use the generic mask generation
maskGen = new ArbROIMaskGenerator(roiArray, src.NumComps, src);
}
return new ROIScaler(src, maskGen, true, sLev, useBlockAligned, encSpec);
}