Package org.apache.pdfbox.jbig2.segments
Class HalftoneRegion
- java.lang.Object
-
- org.apache.pdfbox.jbig2.segments.HalftoneRegion
-
- All Implemented Interfaces:
Region
,SegmentData
public class HalftoneRegion extends java.lang.Object implements Region
This class represents the data of segment type "Halftone region". Parsing is described in 7.4.5, page 67. Decoding procedure in 6.6.5 and 7.4.5.2.
-
-
Field Summary
Fields Modifier and Type Field Description private long
dataHeaderLength
private long
dataHeaderOffset
private long
dataLength
private long
dataOffset
private Bitmap
halftoneRegionBitmap
Decoded dataprivate CombinationOperator
hCombinationOperator
private byte
hDefaultPixel
Halftone segment information field, 7.4.5.1.1private int
hGridHeight
Height of the gray-scale image, 7.4.5.1.2.2private int
hGridWidth
Width of the gray-scale image, 7.4.5.1.2.1private int
hGridX
Horizontal offset of the grid, 7.4.5.1.2.3private int
hGridY
Vertical offset of the grid, 7.4.5.1.2.4private int
hRegionX
Horizontal coordinate of the halftone grid vector, 7.4.5.1.3.1private int
hRegionY
Vertical coordinate of the halftone grod vector, 7.4.5.1.3.2private boolean
hSkipEnabled
private byte
hTemplate
private boolean
isMMREncoded
private java.util.ArrayList<Bitmap>
patterns
Previously decoded data from other regions or dictionaries, stored to use as patterns in this region.private RegionSegmentInformation
regionInfo
Region segment information field, 7.4.1private SegmentHeader
segmentHeader
private SubInputStream
subInputStream
-
Constructor Summary
Constructors Constructor Description HalftoneRegion()
HalftoneRegion(SubInputStream subInputStream)
HalftoneRegion(SubInputStream subInputStream, SegmentHeader segmentHeader)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Bitmap[]
combineGrayScalePlanes(Bitmap[] grayScalePlanes, int j)
private int[][]
computeGrayScaleValues(Bitmap[] grayScalePlanes, int bitsPerValue)
private void
computeSegmentDataStructure()
private int
computeX(int m, int n)
private int
computeY(int m, int n)
CombinationOperator
getCombinationOperator()
protected byte
getHDefaultPixel()
protected int
getHGridHeight()
protected int
getHGridWidth()
protected int
getHGridX()
protected int
getHGridY()
protected int
getHRegionX()
protected int
getHRegionY()
protected byte
getHTemplate()
private java.util.ArrayList<Bitmap>
getPatterns()
Bitmap
getRegionBitmap()
The procedure is described in JBIG2 ISO standard, 6.6.5.RegionSegmentInformation
getRegionInfo()
Simply returns theRegionSegmentInformation
.private int[][]
grayScaleDecoding(int bitsPerValue)
Gray-scale image decoding procedure is special for halftone region decoding and is described in Annex C.5 on page 98.void
init(SegmentHeader header, SubInputStream sis)
Parse the stream and read information of header.protected boolean
isHSkipEnabled()
protected boolean
isMMREncoded()
private void
parseHeader()
private void
renderPattern(int[][] grayScaleValues)
This method draws the pattern into the region bitmap (htReg
), as described in 6.6.5.2, page 42private int
shiftAndFill(int value)
-
-
-
Field Detail
-
subInputStream
private SubInputStream subInputStream
-
segmentHeader
private SegmentHeader segmentHeader
-
dataHeaderOffset
private long dataHeaderOffset
-
dataHeaderLength
private long dataHeaderLength
-
dataOffset
private long dataOffset
-
dataLength
private long dataLength
-
regionInfo
private RegionSegmentInformation regionInfo
Region segment information field, 7.4.1
-
hDefaultPixel
private byte hDefaultPixel
Halftone segment information field, 7.4.5.1.1
-
hCombinationOperator
private CombinationOperator hCombinationOperator
-
hSkipEnabled
private boolean hSkipEnabled
-
hTemplate
private byte hTemplate
-
isMMREncoded
private boolean isMMREncoded
-
hGridWidth
private int hGridWidth
Width of the gray-scale image, 7.4.5.1.2.1
-
hGridHeight
private int hGridHeight
Height of the gray-scale image, 7.4.5.1.2.2
-
hGridX
private int hGridX
Horizontal offset of the grid, 7.4.5.1.2.3
-
hGridY
private int hGridY
Vertical offset of the grid, 7.4.5.1.2.4
-
hRegionX
private int hRegionX
Horizontal coordinate of the halftone grid vector, 7.4.5.1.3.1
-
hRegionY
private int hRegionY
Vertical coordinate of the halftone grod vector, 7.4.5.1.3.2
-
halftoneRegionBitmap
private Bitmap halftoneRegionBitmap
Decoded data
-
patterns
private java.util.ArrayList<Bitmap> patterns
Previously decoded data from other regions or dictionaries, stored to use as patterns in this region.
-
-
Constructor Detail
-
HalftoneRegion
public HalftoneRegion()
-
HalftoneRegion
public HalftoneRegion(SubInputStream subInputStream)
-
HalftoneRegion
public HalftoneRegion(SubInputStream subInputStream, SegmentHeader segmentHeader)
-
-
Method Detail
-
parseHeader
private void parseHeader() throws java.io.IOException, InvalidHeaderValueException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
computeSegmentDataStructure
private void computeSegmentDataStructure() throws java.io.IOException
- Throws:
java.io.IOException
-
getRegionBitmap
public Bitmap getRegionBitmap() throws java.io.IOException, InvalidHeaderValueException
The procedure is described in JBIG2 ISO standard, 6.6.5.- Specified by:
getRegionBitmap
in interfaceRegion
- Returns:
- The decoded
Bitmap
of this region. - Throws:
java.io.IOException
- if an underlying IO operation failsInvalidHeaderValueException
- if a segment header value is invalid
-
renderPattern
private void renderPattern(int[][] grayScaleValues)
This method draws the pattern into the region bitmap (htReg
), as described in 6.6.5.2, page 42
-
getPatterns
private java.util.ArrayList<Bitmap> getPatterns() throws InvalidHeaderValueException, java.io.IOException
- Throws:
java.io.IOException
InvalidHeaderValueException
-
grayScaleDecoding
private int[][] grayScaleDecoding(int bitsPerValue) throws java.io.IOException
Gray-scale image decoding procedure is special for halftone region decoding and is described in Annex C.5 on page 98.- Throws:
java.io.IOException
-
computeGrayScaleValues
private int[][] computeGrayScaleValues(Bitmap[] grayScalePlanes, int bitsPerValue)
-
computeX
private int computeX(int m, int n)
-
computeY
private int computeY(int m, int n)
-
shiftAndFill
private int shiftAndFill(int value)
-
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
-
getCombinationOperator
public CombinationOperator getCombinationOperator()
-
getRegionInfo
public RegionSegmentInformation getRegionInfo()
Description copied from interface:Region
Simply returns theRegionSegmentInformation
.- Specified by:
getRegionInfo
in interfaceRegion
- Returns:
- The
RegionSegmentInformation
.
-
getHTemplate
protected byte getHTemplate()
-
isHSkipEnabled
protected boolean isHSkipEnabled()
-
isMMREncoded
protected boolean isMMREncoded()
-
getHGridWidth
protected int getHGridWidth()
-
getHGridHeight
protected int getHGridHeight()
-
getHGridX
protected int getHGridX()
-
getHGridY
protected int getHGridY()
-
getHRegionX
protected int getHRegionX()
-
getHRegionY
protected int getHRegionY()
-
getHDefaultPixel
protected byte getHDefaultPixel()
-
-