Package org.apache.pdfbox.jbig2.segments
Class HalftoneRegion
java.lang.Object
org.apache.pdfbox.jbig2.segments.HalftoneRegion
- All Implemented Interfaces:
Region
,SegmentData
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
FieldsModifier and TypeFieldDescriptionprivate long
private long
private long
private long
private Bitmap
Decoded dataprivate CombinationOperator
private byte
Halftone segment information field, 7.4.5.1.1private int
Height of the gray-scale image, 7.4.5.1.2.2private int
Width of the gray-scale image, 7.4.5.1.2.1private int
Horizontal offset of the grid, 7.4.5.1.2.3private int
Vertical offset of the grid, 7.4.5.1.2.4private int
Horizontal coordinate of the halftone grid vector, 7.4.5.1.3.1private int
Vertical coordinate of the halftone grod vector, 7.4.5.1.3.2private boolean
private byte
private boolean
Previously decoded data from other regions or dictionaries, stored to use as patterns in this region.private RegionSegmentInformation
Region segment information field, 7.4.1private SegmentHeader
private SubInputStream
-
Constructor Summary
ConstructorsConstructorDescriptionHalftoneRegion
(SubInputStream subInputStream) HalftoneRegion
(SubInputStream subInputStream, SegmentHeader segmentHeader) -
Method Summary
Modifier and TypeMethodDescriptionprivate Bitmap[]
combineGrayScalePlanes
(Bitmap[] grayScalePlanes, int j) private int[][]
computeGrayScaleValues
(Bitmap[] grayScalePlanes, int bitsPerValue) private void
private int
computeX
(int m, int n) private int
computeY
(int m, int n) protected byte
protected int
protected int
protected int
protected int
protected int
protected int
protected byte
The procedure is described in JBIG2 ISO standard, 6.6.5.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
protected boolean
private void
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 Details
-
subInputStream
-
segmentHeader
-
dataHeaderOffset
private long dataHeaderOffset -
dataHeaderLength
private long dataHeaderLength -
dataOffset
private long dataOffset -
dataLength
private long dataLength -
regionInfo
Region segment information field, 7.4.1 -
hDefaultPixel
private byte hDefaultPixelHalftone segment information field, 7.4.5.1.1 -
hCombinationOperator
-
hSkipEnabled
private boolean hSkipEnabled -
hTemplate
private byte hTemplate -
isMMREncoded
private boolean isMMREncoded -
hGridWidth
private int hGridWidthWidth of the gray-scale image, 7.4.5.1.2.1 -
hGridHeight
private int hGridHeightHeight of the gray-scale image, 7.4.5.1.2.2 -
hGridX
private int hGridXHorizontal offset of the grid, 7.4.5.1.2.3 -
hGridY
private int hGridYVertical offset of the grid, 7.4.5.1.2.4 -
hRegionX
private int hRegionXHorizontal coordinate of the halftone grid vector, 7.4.5.1.3.1 -
hRegionY
private int hRegionYVertical coordinate of the halftone grod vector, 7.4.5.1.3.2 -
halftoneRegionBitmap
Decoded data -
patterns
Previously decoded data from other regions or dictionaries, stored to use as patterns in this region.
-
-
Constructor Details
-
HalftoneRegion
public HalftoneRegion() -
HalftoneRegion
-
HalftoneRegion
-
-
Method Details
-
parseHeader
-
computeSegmentDataStructure
- Throws:
IOException
-
getRegionBitmap
The procedure is described in JBIG2 ISO standard, 6.6.5.- Specified by:
getRegionBitmap
in interfaceRegion
- Returns:
- The decoded
Bitmap
of this region. - Throws:
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
-
grayScaleDecoding
Gray-scale image decoding procedure is special for halftone region decoding and is described in Annex C.5 on page 98.- Throws:
IOException
-
combineGrayScalePlanes
-
computeGrayScaleValues
-
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, 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 invalidIOException
- if an underlying IO operation fails
-
getCombinationOperator
-
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()
-