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 longdataHeaderLengthprivate longdataHeaderOffsetprivate longdataLengthprivate longdataOffsetprivate BitmaphalftoneRegionBitmapDecoded dataprivate CombinationOperatorhCombinationOperatorprivate bytehDefaultPixelHalftone segment information field, 7.4.5.1.1private inthGridHeightHeight of the gray-scale image, 7.4.5.1.2.2private inthGridWidthWidth of the gray-scale image, 7.4.5.1.2.1private inthGridXHorizontal offset of the grid, 7.4.5.1.2.3private inthGridYVertical offset of the grid, 7.4.5.1.2.4private inthRegionXHorizontal coordinate of the halftone grid vector, 7.4.5.1.3.1private inthRegionYVertical coordinate of the halftone grod vector, 7.4.5.1.3.2private booleanhSkipEnabledprivate bytehTemplateprivate booleanisMMREncodedprivate java.util.ArrayList<Bitmap>patternsPreviously decoded data from other regions or dictionaries, stored to use as patterns in this region.private RegionSegmentInformationregionInfoRegion segment information field, 7.4.1private SegmentHeadersegmentHeaderprivate SubInputStreamsubInputStream
-
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 voidcomputeSegmentDataStructure()private intcomputeX(int m, int n)private intcomputeY(int m, int n)CombinationOperatorgetCombinationOperator()protected bytegetHDefaultPixel()protected intgetHGridHeight()protected intgetHGridWidth()protected intgetHGridX()protected intgetHGridY()protected intgetHRegionX()protected intgetHRegionY()protected bytegetHTemplate()private java.util.ArrayList<Bitmap>getPatterns()BitmapgetRegionBitmap()The procedure is described in JBIG2 ISO standard, 6.6.5.RegionSegmentInformationgetRegionInfo()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.voidinit(SegmentHeader header, SubInputStream sis)Parse the stream and read information of header.protected booleanisHSkipEnabled()protected booleanisMMREncoded()private voidparseHeader()private voidrenderPattern(int[][] grayScaleValues)This method draws the pattern into the region bitmap (htReg), as described in 6.6.5.2, page 42private intshiftAndFill(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.IOExceptionInvalidHeaderValueException
-
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:
getRegionBitmapin interfaceRegion- Returns:
- The decoded
Bitmapof 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.IOExceptionInvalidHeaderValueException
-
grayScaleDecoding
private int[][] grayScaleDecoding(int bitsPerValue) throws java.io.IOExceptionGray-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: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
-
getCombinationOperator
public CombinationOperator getCombinationOperator()
-
getRegionInfo
public RegionSegmentInformation getRegionInfo()
Description copied from interface:RegionSimply returns theRegionSegmentInformation.- Specified by:
getRegionInfoin 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()
-
-