Class GenericRefinementRegion
java.lang.Object
org.apache.pdfbox.jbig2.segments.GenericRefinementRegion
- All Implemented Interfaces:
Region, SegmentData
Handles a JBIG2 Generic Refinement Region segment (§7.4.7).
This class is responsible for segment-level concerns only: parsing the
region segment information and flags from the bitstream, resolving the
reference bitmap, and delegating pixel decoding to
GenericRefinementRegionDecodingProcedure, which implements the
pure algorithm defined in §6.3.5.6.
Segment types (§7.4.7)
The three generic refinement region segment types — intermediate, immediate, and immediate lossless — share an identical data encoding. They differ only in how the decoded bitmap is acted upon during page image composition (§8.2):
- Intermediate generic refinement region — the decoded bitmap is stored but not yet composited onto the page buffer.
- Immediate generic refinement region — the decoded bitmap is composited onto the page buffer immediately using lossy encoding.
- Immediate lossless generic refinement region — as above but using lossless encoding.
Usage modes
- Header-driven (standalone segment):
Initialise via
init(SegmentHeader, SubInputStream). The reference bitmap is resolved from referred-to segments or, if none are present, from the current page buffer (§7.4.7.4). Per Table 35,GRREFERENCEDXandGRREFERENCEDYare implicitly zero in this mode. - Parameter-driven:
Call
setParameters(CX, ArithmeticDecoder, short, int, int, Bitmap, int, int, boolean, short[], short[])to supply the sharedArithmeticDecoder,CX, reference bitmap, and offsets before callinggetRegionBitmap().
Deprecated: callers should migrate to invokingGenericRefinementRegionDecodingProcedure.decode(ArithmeticDecoder, CX, int, int, short, boolean, Bitmap, int, int, short[], short[])directly.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArithmeticDecoderprivate CXprivate short[]Generic refinement region segment AT flags, 7.4.7.3private short[]private booleanGeneric refinement region segment flags, 7.4.7.2private Bitmapprivate BitmapVariables for decodingprivate intprivate intprivate RegionSegmentInformationRegion segment information flags, 7.4.1private SegmentHeaderprivate SubInputStreamprivate short -
Constructor Summary
ConstructorsConstructorDescriptionGenericRefinementRegion(SubInputStream subInputStream) GenericRefinementRegion(SubInputStream subInputStream, SegmentHeader segmentHeader) -
Method Summary
Modifier and TypeMethodDescriptionprivate BitmapDecode using a template and arithmetic coding, as described in 6.3.5.6Simply returns theRegionSegmentInformation.voidinit(SegmentHeader header, SubInputStream sis) Parse the stream and read information of header.private voidParses the flags described in JBIG2 ISO standard: 7.4.7.2 Generic refinement region segment flags 7.4.7.3 Generic refinement region segment AT flagsprivate voidvoidsetPageBitmap(Bitmap pageBitmap) Call this to pass the page bitmap in case there is no reference bitmap.protected voidsetParameters(CX cx, ArithmeticDecoder arithmeticDecoder, short grTemplate, int regionWidth, int regionHeight, Bitmap grReference, int grReferenceDX, int grReferenceDY, boolean isTPGRon, short[] grAtX, short[] grAtY) Deprecated.UseGenericRefinementRegionDecodingProcedure.decode(ArithmeticDecoder, CX, int, int, short, boolean, Bitmap, int, int, short[], short[])directly, supplying the sharedArithmeticDecoderandCXas arguments.
-
Field Details
-
subInputStream
-
segmentHeader
-
regionInfo
Region segment information flags, 7.4.1 -
isTPGROn
private boolean isTPGROnGeneric refinement region segment flags, 7.4.7.2 -
templateID
private short templateID -
grAtX
private short[] grAtXGeneric refinement region segment AT flags, 7.4.7.3 -
grAtY
private short[] grAtY -
referenceBitmap
Variables for decoding -
referenceDX
private int referenceDX -
referenceDY
private int referenceDY -
arithDecoder
-
cx
-
pageBitmap
-
-
Constructor Details
-
GenericRefinementRegion
public GenericRefinementRegion() -
GenericRefinementRegion
-
GenericRefinementRegion
-
-
Method Details
-
parseHeader
Parses the flags described in JBIG2 ISO standard:- 7.4.7.2 Generic refinement region segment flags
- 7.4.7.3 Generic refinement region segment AT flags
- Throws:
IOException
-
readAtPixels
- Throws:
IOException
-
getRegionBitmap
public Bitmap getRegionBitmap() throws IOException, IntegerMaxValueException, InvalidHeaderValueExceptionDecode using a template and arithmetic coding, as described in 6.3.5.6- Specified by:
getRegionBitmapin interfaceRegion- Returns:
- The decoded region as
Bitmap. - Throws:
IOException- if an underlying IO operation failsInvalidHeaderValueException- if a segment header value is invalidIntegerMaxValueException- if the maximum value limit of an integer is exceeded
-
setPageBitmap
Call this to pass the page bitmap in case there is no reference bitmap.- Parameters:
pageBitmap-
-
getGrReference
private Bitmap getGrReference() throws IntegerMaxValueException, InvalidHeaderValueException, IOException -
init
Description copied from interface:SegmentDataParse the stream and read information of header.- Specified by:
initin interfaceSegmentData- Parameters:
header- - The segments' header (to make referred-to segments available in data part).sis- - WrappedImageInputStreamintoSubInputStream.- Throws:
IOException- if an underlying IO operation fails
-
setParameters
@Deprecated protected void setParameters(CX cx, ArithmeticDecoder arithmeticDecoder, short grTemplate, int regionWidth, int regionHeight, Bitmap grReference, int grReferenceDX, int grReferenceDY, boolean isTPGRon, short[] grAtX, short[] grAtY) Deprecated.UseGenericRefinementRegionDecodingProcedure.decode(ArithmeticDecoder, CX, int, int, short, boolean, Bitmap, int, int, short[], short[])directly, supplying the sharedArithmeticDecoderandCXas arguments. This method will be removed in the next major release. -
getRegionInfo
Description copied from interface:RegionSimply returns theRegionSegmentInformation.- Specified by:
getRegionInfoin interfaceRegion- Returns:
- The
RegionSegmentInformation.
-
GenericRefinementRegionDecodingProcedure.Template.