Package org.apache.pdfbox.jbig2.segments
Class PatternDictionary
- java.lang.Object
-
- org.apache.pdfbox.jbig2.segments.PatternDictionary
-
- All Implemented Interfaces:
Dictionary,SegmentData
public class PatternDictionary extends java.lang.Object implements Dictionary
This class represents the segment type "Pattern dictionary", 7.4.4.
-
-
Field Summary
Fields Modifier and Type Field Description private longdataHeaderLengthprivate longdataHeaderOffsetSegment data structure (only necessary if MMR is used)private longdataLengthprivate longdataOffsetprivate short[]gbAtXprivate short[]gbAtYprivate intgrayMaxLargest gray-scale value, 7.4.4.1.4 Value: one less than the number of patterns defined in this pattern dictionaryprivate shorthdpHeightHeight of the patterns in the pattern dictionary, 7.4.4.1.3private shorthdpWidthWidth of the patterns in the pattern dictionary, 7.4.4.1.2private bytehdTemplateprivate booleanisMMREncodedPattern dictionary flags, 7.4.4.1.1private java.util.ArrayList<Bitmap>patternsDecoded bitmaps, stored to be used by segments, that refer to itprivate SubInputStreamsubInputStream
-
Constructor Summary
Constructors Constructor Description PatternDictionary()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcheckInput()private voidcomputeSegmentDataStructure()private voidextractPatterns(Bitmap collectiveBitmap)java.util.ArrayList<Bitmap>getDictionary()This method decodes a pattern dictionary segment and returns an array ofBitmaps.protected intgetGrayMax()protected shortgetHdpHeight()protected shortgetHdpWidth()protected bytegetHdTemplate()voidinit(SegmentHeader header, SubInputStream sis)Parse the stream and read information of header.protected booleanisMMREncoded()private voidparseHeader()private voidreadGrayMax()private voidreadIsMMREncoded()private voidreadPatternWidthAndHeight()private voidreadTemplate()private voidsetGbAtPixels()
-
-
-
Field Detail
-
subInputStream
private SubInputStream subInputStream
-
dataHeaderOffset
private long dataHeaderOffset
Segment data structure (only necessary if MMR is used)
-
dataHeaderLength
private long dataHeaderLength
-
dataOffset
private long dataOffset
-
dataLength
private long dataLength
-
gbAtX
private short[] gbAtX
-
gbAtY
private short[] gbAtY
-
isMMREncoded
private boolean isMMREncoded
Pattern dictionary flags, 7.4.4.1.1
-
hdTemplate
private byte hdTemplate
-
hdpWidth
private short hdpWidth
Width of the patterns in the pattern dictionary, 7.4.4.1.2
-
hdpHeight
private short hdpHeight
Height of the patterns in the pattern dictionary, 7.4.4.1.3
-
patterns
private java.util.ArrayList<Bitmap> patterns
Decoded bitmaps, stored to be used by segments, that refer to it
-
grayMax
private int grayMax
Largest gray-scale value, 7.4.4.1.4 Value: one less than the number of patterns defined in this pattern dictionary
-
-
Method Detail
-
parseHeader
private void parseHeader() throws java.io.IOException, InvalidHeaderValueException- Throws:
java.io.IOExceptionInvalidHeaderValueException
-
readTemplate
private void readTemplate() throws java.io.IOException- Throws:
java.io.IOException
-
readIsMMREncoded
private void readIsMMREncoded() throws java.io.IOException- Throws:
java.io.IOException
-
readPatternWidthAndHeight
private void readPatternWidthAndHeight() throws java.io.IOException- Throws:
java.io.IOException
-
readGrayMax
private void readGrayMax() throws java.io.IOException- Throws:
java.io.IOException
-
computeSegmentDataStructure
private void computeSegmentDataStructure() throws java.io.IOException- Throws:
java.io.IOException
-
checkInput
private void checkInput() throws InvalidHeaderValueException- Throws:
InvalidHeaderValueException
-
getDictionary
public java.util.ArrayList<Bitmap> getDictionary() throws java.io.IOException, InvalidHeaderValueException
This method decodes a pattern dictionary segment and returns an array ofBitmaps. Each of thisBitmaps is a pattern.
The procedure is described in 6.7.5 (page 43).- Specified by:
getDictionaryin interfaceDictionary- Returns:
- An array of
Bitmaps as result of the decoding procedure. - Throws:
java.io.IOException- if an underlying IO operation failsInvalidHeaderValueException- if the segment header value is invalid
-
extractPatterns
private void extractPatterns(Bitmap collectiveBitmap)
-
setGbAtPixels
private void setGbAtPixels()
-
init
public void init(SegmentHeader header, SubInputStream sis) throws InvalidHeaderValueException, java.io.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 invalidjava.io.IOException- if an underlying IO operation fails
-
isMMREncoded
protected boolean isMMREncoded()
-
getHdTemplate
protected byte getHdTemplate()
-
getHdpWidth
protected short getHdpWidth()
-
getHdpHeight
protected short getHdpHeight()
-
getGrayMax
protected int getGrayMax()
-
-