genericRegionAdaptiveTemplateX[1] = readATValue();
genericRegionAdaptiveTemplateY[1] = readATValue();
}
if (noOfReferedToSegments == 0 || inlineImage) {
PageInformationSegment pageSegment = decoder.findPageSegement(segmentHeader.getPageAssociation());
JBIG2Bitmap pageBitmap = pageSegment.getPageBitmap();
if (pageSegment.getPageBitmapHeight() == -1 && regionBitmapYLocation + regionBitmapHeight > pageBitmap.getHeight()) {
pageBitmap.expand(regionBitmapYLocation + regionBitmapHeight, pageSegment.getPageInformationFlags().getFlagValue(PageInformationFlags.DEFAULT_PIXEL_VALUE));
}
}
if (noOfReferedToSegments > 1) {
if(JBIG2StreamDecoder.debug)
System.out.println("Bad reference in JBIG2 generic refinement Segment");
return;
}
JBIG2Bitmap referedToBitmap;
if (noOfReferedToSegments == 1) {
referedToBitmap = decoder.findBitmap(referedToSegments[0]);
} else {
PageInformationSegment pageSegment = decoder.findPageSegement(segmentHeader.getPageAssociation());
JBIG2Bitmap pageBitmap = pageSegment.getPageBitmap();
referedToBitmap = pageBitmap.getSlice(regionBitmapXLocation, regionBitmapYLocation, regionBitmapWidth, regionBitmapHeight);
}
arithmeticDecoder.resetRefinementStats(template, null);
arithmeticDecoder.start();
boolean typicalPredictionGenericRefinementOn = refinementRegionFlags.getFlagValue(RefinementRegionFlags.TPGDON) != 0;
JBIG2Bitmap bitmap = new JBIG2Bitmap(regionBitmapWidth, regionBitmapHeight, arithmeticDecoder, huffmanDecoder, mmrDecoder);
bitmap.readGenericRefinementRegion(template, typicalPredictionGenericRefinementOn, referedToBitmap, 0, 0, genericRegionAdaptiveTemplateX, genericRegionAdaptiveTemplateY);
if (inlineImage) {
PageInformationSegment pageSegment = decoder.findPageSegement(segmentHeader.getPageAssociation());
JBIG2Bitmap pageBitmap = pageSegment.getPageBitmap();
int extCombOp = regionFlags.getFlagValue(RegionFlags.EXTERNAL_COMBINATION_OPERATOR);
pageBitmap.combine(bitmap, regionBitmapXLocation, regionBitmapYLocation, extCombOp);
} else {