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 long
dataHeaderLength
private long
dataHeaderOffset
Segment data structure (only necessary if MMR is used)private long
dataLength
private long
dataOffset
private short[]
gbAtX
private short[]
gbAtY
private int
grayMax
Largest gray-scale value, 7.4.4.1.4 Value: one less than the number of patterns defined in this pattern dictionaryprivate short
hdpHeight
Height of the patterns in the pattern dictionary, 7.4.4.1.3private short
hdpWidth
Width of the patterns in the pattern dictionary, 7.4.4.1.2private byte
hdTemplate
private boolean
isMMREncoded
Pattern dictionary flags, 7.4.4.1.1private java.util.ArrayList<Bitmap>
patterns
Decoded bitmaps, stored to be used by segments, that refer to itprivate SubInputStream
subInputStream
-
Constructor Summary
Constructors Constructor Description PatternDictionary()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkInput()
private void
computeSegmentDataStructure()
private void
extractPatterns(Bitmap collectiveBitmap)
java.util.ArrayList<Bitmap>
getDictionary()
This method decodes a pattern dictionary segment and returns an array ofBitmap
s.protected int
getGrayMax()
protected short
getHdpHeight()
protected short
getHdpWidth()
protected byte
getHdTemplate()
void
init(SegmentHeader header, SubInputStream sis)
Parse the stream and read information of header.protected boolean
isMMREncoded()
private void
parseHeader()
private void
readGrayMax()
private void
readIsMMREncoded()
private void
readPatternWidthAndHeight()
private void
readTemplate()
private void
setGbAtPixels()
-
-
-
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.IOException
InvalidHeaderValueException
-
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 ofBitmap
s. Each of thisBitmap
s is a pattern.
The procedure is described in 6.7.5 (page 43).- Specified by:
getDictionary
in interfaceDictionary
- Returns:
- An array of
Bitmap
s 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: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:
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()
-
-