Package org.apache.pdfbox.jbig2.segments
Class GenericRefinementRegion
java.lang.Object
org.apache.pdfbox.jbig2.segments.GenericRefinementRegion
- All Implemented Interfaces:
Region
,SegmentData
This class represents a generic refinement region and implements the procedure described in JBIG2 ISO standard, 6.3
and 7.4.7.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
private static class
private static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArithmeticDecoder
private CX
private boolean[]
private short[]
Generic refinement region segment AT flags, 7.4.7.3private short[]
private boolean
Generic refinement region segment flags, 7.4.7.2private boolean
If true, AT pixels are not on their nominal location and have to be overridden.private Bitmap
Variables for decodingprivate int
private int
private Bitmap
Decoded data as pixel values (use row stride/width to wrap line)private RegionSegmentInformation
Region segment information flags, 7.4.1private SegmentHeader
private SubInputStream
private static final GenericRefinementRegion.Template
private static final GenericRefinementRegion.Template
private GenericRefinementRegion.Template
private short
-
Constructor Summary
ConstructorsConstructorDescriptionGenericRefinementRegion
(SubInputStream subInputStream) GenericRefinementRegion
(SubInputStream subInputStream, SegmentHeader segmentHeader) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
decodeOptimized
(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int lineOffset) private int
private void
decodeTemplate
(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int lineOffset, int byteIndex, int currentLine, int refByteIndex, GenericRefinementRegion.Template templateFormation) private void
decodeTypicalPredictedLine
(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride) private void
decodeTypicalPredictedLineTemplate0
(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int byteIndex, int currentLine, int refByteIndex) private void
decodeTypicalPredictedLineTemplate1
(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int byteIndex, int currentLine, int refByteIndex) private Bitmap
private byte
Decode using a template and arithmetic coding, as described in 6.3.5.6Simply returns theRegionSegmentInformation
.void
init
(SegmentHeader header, SubInputStream sis) Parse the stream and read information of header.private int
overrideAtTemplate0
(int context, int x, int y, int result, int minorX) private void
Parses the flags described in JBIG2 ISO standard: 7.4.7.2 Generic refinement region segment flags 7.4.7.3 Generic refinement refion segment AT flagsprivate void
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) private void
-
Field Details
-
T0
-
T1
-
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 -
template
-
grAtX
private short[] grAtXGeneric refinement region segment AT flags, 7.4.7.3 -
grAtY
private short[] grAtY -
regionBitmap
Decoded data as pixel values (use row stride/width to wrap line) -
referenceBitmap
Variables for decoding -
referenceDX
private int referenceDX -
referenceDY
private int referenceDY -
arithDecoder
-
cx
-
override
private boolean overrideIf true, AT pixels are not on their nominal location and have to be overridden. -
grAtOverride
private boolean[] grAtOverride
-
-
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 refion 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:
getRegionBitmap
in 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
-
decodeSLTP
- Throws:
IOException
-
getGrReference
private Bitmap getGrReference() throws IntegerMaxValueException, InvalidHeaderValueException, IOException -
decodeOptimized
private void decodeOptimized(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int lineOffset) throws IOException - Throws:
IOException
-
decodeTemplate
private void decodeTemplate(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int lineOffset, int byteIndex, int currentLine, int refByteIndex, GenericRefinementRegion.Template templateFormation) throws IOException - Throws:
IOException
-
updateOverride
private void updateOverride() -
decodeTypicalPredictedLine
private void decodeTypicalPredictedLine(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride) throws IOException - Throws:
IOException
-
decodeTypicalPredictedLineTemplate0
private void decodeTypicalPredictedLineTemplate0(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int byteIndex, int currentLine, int refByteIndex) throws IOException - Throws:
IOException
-
decodeTypicalPredictedLineTemplate1
private void decodeTypicalPredictedLineTemplate1(int lineNumber, int width, int rowStride, int refRowStride, int paddedWidth, int deltaRefStride, int byteIndex, int currentLine, int refByteIndex) throws IOException - Throws:
IOException
-
overrideAtTemplate0
private int overrideAtTemplate0(int context, int x, int y, int result, int minorX) throws IOException - Throws:
IOException
-
getPixel
- Throws:
IOException
-
init
Description copied from interface:SegmentData
Parse the stream and read information of header.- Specified by:
init
in interfaceSegmentData
- Parameters:
header
- - The segments' header (to make referred-to segments available in data part).sis
- - WrappedImageInputStream
intoSubInputStream
.- Throws:
IOException
- if an underlying IO operation fails
-
setParameters
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) -
getRegionInfo
Description copied from interface:Region
Simply returns theRegionSegmentInformation
.- Specified by:
getRegionInfo
in interfaceRegion
- Returns:
- The
RegionSegmentInformation
.
-