Package org.apache.pdfbox.jbig2.segments
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 -
Constructor Summary
ConstructorsConstructorDescriptionGenericRefinementRegion(SubInputStream subInputStream) GenericRefinementRegion(SubInputStream subInputStream, SegmentHeader segmentHeader) -
Method Summary
Modifier and TypeMethodDescriptionDecode 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.voidsetPageBitmap(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.
-
Constructor Details
-
GenericRefinementRegion
public GenericRefinementRegion() -
GenericRefinementRegion
-
GenericRefinementRegion
-
-
Method Details
-
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-
-
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.