Class GenericRegion
java.lang.Object
org.apache.pdfbox.jbig2.segments.GenericRegion
- All Implemented Interfaces:
Region, SegmentData
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ArithmeticDecoderprivate CXprivate longprivate longprivate longprivate longprivate boolean[]private short[]Generic region segment AT flags, 7.4.6.3private short[]private byteprivate booleanprivate booleanprivate MMRDecompressorprivate booleanIf true, AT pixels are not on their nominal location and have to be overriddenprivate BitmapDecoded data as pixel values (use row stride/width to wrap line)private RegionSegmentInformationRegion segment information field, 7.4.1private SubInputStreamprivate booleanGeneric region segment flags, 7.4.6.2 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidprivate voidcopyLineAbove(int lineNumber) Each pixel gets the value from the corresponding pixel of the row above.private voiddecodeLine(int lineNumber, int width, int rowStride, int paddedWidth) private intprivate voiddecodeTemplate0a(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) private voiddecodeTemplate0b(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) private voiddecodeTemplate1(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) private voiddecodeTemplate2(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) private voiddecodeTemplate3(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) protected short[]getGbAtX()protected short[]getGbAtY()protected byteprivate bytegetPixel(int x, int y) The procedure is described in 6.2.5.7, page 17.Simply returns theRegionSegmentInformation.voidinit(SegmentHeader header, SubInputStream sis) Parse the stream and read information of header.protected booleanprotected booleanisTPGDon()private intoverrideAtTemplate0a(int context, int x, int y, int result, int minorX, int toShift) private intoverrideAtTemplate0b(int context, int x, int y, int result, int minorX, int toShift) private intoverrideAtTemplate1(int context, int x, int y, int result, int minorX) private intoverrideAtTemplate2(int context, int x, int y, int result, int minorX) private intoverrideAtTemplate3(int context, int x, int y, int result, int minorX) private voidprivate voidreadGbAtPixels(int amountOfGbAt) protected voidSimply sets the memory-critical bitmap of this region tonull.private voidsetOverrideFlag(int index) protected voidsetParameters(boolean isMMREncoded, byte sdTemplate, boolean isTPGDon, boolean useSkip, short[] sdATX, short[] sdATY, int symWidth, int hcHeight, CX cx, ArithmeticDecoder arithmeticDecoder) protected voidsetParameters(boolean isMMREncoded, long dataOffset, long dataLength, int gbh, int gbw) Used bySymbolDictionary.protected voidsetParameters(boolean isMMREncoded, long dataOffset, long dataLength, int gbh, int gbw, byte gbTemplate, boolean isTPGDon, boolean useSkip, short[] gbAtX, short[] gbAtY) Used byPatternDictionaryandHalftoneRegion.private voidprotected boolean
-
Field Details
-
subInputStream
-
dataHeaderOffset
private long dataHeaderOffset -
dataHeaderLength
private long dataHeaderLength -
dataOffset
private long dataOffset -
dataLength
private long dataLength -
regionInfo
Region segment information field, 7.4.1 -
useExtTemplates
private boolean useExtTemplatesGeneric region segment flags, 7.4.6.2 -
isTPGDon
private boolean isTPGDon -
gbTemplate
private byte gbTemplate -
isMMREncoded
private boolean isMMREncoded -
gbAtX
private short[] gbAtXGeneric region segment AT flags, 7.4.6.3 -
gbAtY
private short[] gbAtY -
gbAtOverride
private boolean[] gbAtOverride -
override
private boolean overrideIf true, AT pixels are not on their nominal location and have to be overridden -
regionBitmap
Decoded data as pixel values (use row stride/width to wrap line) -
arithDecoder
-
cx
-
mmrDecompressor
-
-
Constructor Details
-
GenericRegion
public GenericRegion() -
GenericRegion
-
-
Method Details
-
parseHeader
-
readGbAtPixels
- Throws:
IOException
-
computeSegmentDataStructure
- Throws:
IOException
-
getRegionBitmap
The procedure is described in 6.2.5.7, page 17.- Specified by:
getRegionBitmapin interfaceRegion- Returns:
- The decoded
Bitmapof this region. - Throws:
IOException- if an underlying IO operation fails
-
decodeSLTP
- Throws:
IOException
-
decodeLine
private void decodeLine(int lineNumber, int width, int rowStride, int paddedWidth) throws IOException - Throws:
IOException
-
copyLineAbove
private void copyLineAbove(int lineNumber) Each pixel gets the value from the corresponding pixel of the row above. Line 0 cannot get copied values (source will be -1, doesn't exist).- Parameters:
lineNumber- - Coordinate of the row that should be set.
-
decodeTemplate0a
private void decodeTemplate0a(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) throws IOException - Throws:
IOException
-
decodeTemplate0b
private void decodeTemplate0b(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) throws IOException - Throws:
IOException
-
decodeTemplate1
private void decodeTemplate1(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) throws IOException - Throws:
IOException
-
decodeTemplate2
private void decodeTemplate2(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) throws IOException - Throws:
IOException
-
decodeTemplate3
private void decodeTemplate3(int lineNumber, int width, int rowStride, int paddedWidth, int byteIndex, int idx) throws IOException - Throws:
IOException
-
updateOverrideFlags
private void updateOverrideFlags() -
setOverrideFlag
private void setOverrideFlag(int index) -
overrideAtTemplate0a
private int overrideAtTemplate0a(int context, int x, int y, int result, int minorX, int toShift) throws IOException - Throws:
IOException
-
overrideAtTemplate0b
private int overrideAtTemplate0b(int context, int x, int y, int result, int minorX, int toShift) throws IOException - Throws:
IOException
-
overrideAtTemplate1
private int overrideAtTemplate1(int context, int x, int y, int result, int minorX) throws IOException - Throws:
IOException
-
overrideAtTemplate2
private int overrideAtTemplate2(int context, int x, int y, int result, int minorX) throws IOException - Throws:
IOException
-
overrideAtTemplate3
private int overrideAtTemplate3(int context, int x, int y, int result, int minorX) throws IOException - Throws:
IOException
-
getPixel
- Throws:
IOException
-
setParameters
protected void setParameters(boolean isMMREncoded, long dataOffset, long dataLength, int gbh, int gbw) Used bySymbolDictionary.- Parameters:
isMMREncoded- the data is MMR encodeddataOffset- the offsetdataLength- the length of the datagbh- bitmap heightgbw- bitmap width
-
setParameters
protected void setParameters(boolean isMMREncoded, byte sdTemplate, boolean isTPGDon, boolean useSkip, short[] sdATX, short[] sdATY, int symWidth, int hcHeight, CX cx, ArithmeticDecoder arithmeticDecoder) - Parameters:
isMMREncoded- the data is MMR encodedsdTemplate- sd templateisTPGDon- is TPGDonuseSkip- use skipsdATX- x values gbA pixelssdATY- y values gbA pixelssymWidth- bitmap widthhcHeight- bitmap heightcx- context for the arithmetic decoderarithmeticDecoder- the arithmetic decode to be used Used bySymbolDictionary.
-
setParameters
protected void setParameters(boolean isMMREncoded, long dataOffset, long dataLength, int gbh, int gbw, byte gbTemplate, boolean isTPGDon, boolean useSkip, short[] gbAtX, short[] gbAtY) Used byPatternDictionaryandHalftoneRegion.- Parameters:
isMMREncoded- the data is MMR encodeddataOffset- the offsetdataLength- the length of the datagbh- bitmap heightgbw- bitmap widthgbTemplate- gb templateisTPGDon- is TPGDonuseSkip- use skipgbAtX- x values of gbA pixelsgbAtY- y values of gbA pixels
-
resetBitmap
protected void resetBitmap()Simply sets the memory-critical bitmap of this region tonull. -
init
public void init(SegmentHeader header, SubInputStream sis) throws InvalidHeaderValueException, IOException 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:
InvalidHeaderValueException- if the segment header value is invalidIOException- if an underlying IO operation fails
-
getRegionInfo
Description copied from interface:RegionSimply returns theRegionSegmentInformation.- Specified by:
getRegionInfoin interfaceRegion- Returns:
- The
RegionSegmentInformation.
-
useExtTemplates
protected boolean useExtTemplates() -
isTPGDon
protected boolean isTPGDon() -
getGbTemplate
protected byte getGbTemplate() -
isMMREncoded
protected boolean isMMREncoded() -
getGbAtX
protected short[] getGbAtX() -
getGbAtY
protected short[] getGbAtY()
-