Top Description Fields Constructors Methods
org.apache.pdfbox.jbig2.segments

public Class GenericRegion

extends Object
implements Region
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.jbig2.Region, org.apache.pdfbox.jbig2.SegmentData
Imports
java.io.IOException, org.apache.pdfbox.jbig2.Bitmap, .Region, .SegmentHeader, org.apache.pdfbox.jbig2.decoder.arithmetic.ArithmeticDecoder, .CX, org.apache.pdfbox.jbig2.decoder.mmr.MMRDecompressor, org.apache.pdfbox.jbig2.err.InvalidHeaderValueException, org.apache.pdfbox.jbig2.io.SubInputStream

This class represents a generic region segment.
Parsing is done as described in 7.4.5.
Decoding procedure is done as described in 6.2.5.7 and 7.4.6.4.

Field Summary

Modifier and TypeField and Description
private ArithmeticDecoder
private CX
private long
private long
private long
private long
private boolean[]
private short[]
gbAtX

Generic region segment AT flags, 7.4.6.3

private short[]
private byte
private boolean
private boolean
private MMRDecompressor
private boolean
override

If true, AT pixels are not on their nominal location and have to be overridden

private Bitmap
regionBitmap

Decoded data as pixel values (use row stride/width to wrap line)

private RegionSegmentInformation
regionInfo

Region segment information field, 7.4.1

private SubInputStream
private boolean
useExtTemplates

Generic region segment flags, 7.4.6.2

Constructor Summary

AccessConstructor and Description
public
public
GenericRegion(final SubInputStream subInputStream)

Method Summary

Modifier and TypeMethod and Description
private void
private void
copyLineAbove(final int
- Coordinate of the row that should be set.
lineNumber
)

Each pixel gets the value from the corresponding pixel of the row above.

private void
decodeLine(final int lineNumber, final int width, final int rowStride, final int paddedWidth)

private int
private void
decodeTemplate0a(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx)

private void
decodeTemplate0b(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx)

private void
decodeTemplate1(final int lineNumber, int width, final int rowStride, final int paddedWidth, int byteIndex, int idx)

private void
decodeTemplate2(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx)

private void
decodeTemplate3(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx)

protected short[]
protected short[]
protected byte
private byte
getPixel(final int x, final int y)

public Bitmap

Returns:

The decoded Bitmap of this region.
getRegionBitmap
()

Implements org.apache.pdfbox.jbig2.Region.getRegionBitmap.

The procedure is described in 6.2.5.7, page 17.

public RegionSegmentInformation
public void
init(final SegmentHeader
- The segments' header (to make referred-to segments available in data part).
header
,
final SubInputStream
- Wrapped ImageInputStream into SubInputStream.
sis
)

Implements org.apache.pdfbox.jbig2.SegmentData.init.

Parse the stream and read information of header.

protected boolean
protected boolean
private int
overrideAtTemplate0a(int context, final int x, final int y, final int result, final int minorX, final int toShift)

private int
overrideAtTemplate0b(int context, final int x, final int y, final int result, final int minorX, final int toShift)

private int
overrideAtTemplate1(int context, final int x, final int y, final int result, final int minorX)

private int
overrideAtTemplate2(int context, final int x, final int y, final int result, final int minorX)

private int
overrideAtTemplate3(int context, final int x, final int y, final int result, final int minorX)

private void
private void
readGbAtPixels(final int amountOfGbAt)

protected void
resetBitmap()

Simply sets the memory-critical bitmap of this region to null.

private void
setOverrideFlag(final int index)

protected void
setParameters(final boolean
the data is MMR encoded
isMMREncoded
,
final long
the offset
dataOffset
,
final long
the length of the data
dataLength
,
final int
bitmap height
gbh
,
final int
bitmap width
gbw
)

Used by SymbolDictionary.

protected void
setParameters(final boolean
the data is MMR encoded
isMMREncoded
,
final byte
sd template
sdTemplate
,
final boolean
is TPGDon
isTPGDon
,
final boolean
use skip
useSkip
,
final short[]
x values gbA pixels
sdATX
,
final short[]
y values gbA pixels
sdATY
,
final int
bitmap width
symWidth
,
final int
bitmap height
hcHeight
,
final CX
context for the arithmetic decoder
cx
,
final ArithmeticDecoder
the arithmetic decode to be used Used by SymbolDictionary.
arithmeticDecoder
)

protected void
setParameters(final boolean
the data is MMR encoded
isMMREncoded
,
final long
the offset
dataOffset
,
final long
the length of the data
dataLength
,
final int
bitmap height
gbh
,
final int
bitmap width
gbw
,
final byte
gb template
gbTemplate
,
final boolean
is TPGDon
isTPGDon
,
final boolean
use skip
useSkip
,
final short[]
x values of gbA pixels
gbAtX
,
final short[]
y values of gbA pixels
gbAtY
)

Used by PatternDictionary and HalftoneRegion.

private void
protected boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

arithDecoderback to summary
private ArithmeticDecoder arithDecoder
cxback to summary
private CX cx
dataHeaderLengthback to summary
private long dataHeaderLength
dataHeaderOffsetback to summary
private long dataHeaderOffset
dataLengthback to summary
private long dataLength
dataOffsetback to summary
private long dataOffset
gbAtOverrideback to summary
private boolean[] gbAtOverride
gbAtXback to summary
private short[] gbAtX

Generic region segment AT flags, 7.4.6.3

gbAtYback to summary
private short[] gbAtY
gbTemplateback to summary
private byte gbTemplate
isMMREncodedback to summary
private boolean isMMREncoded
isTPGDonback to summary
private boolean isTPGDon
mmrDecompressorback to summary
private MMRDecompressor mmrDecompressor
overrideback to summary
private boolean override

If true, AT pixels are not on their nominal location and have to be overridden

regionBitmapback to summary
private Bitmap regionBitmap

Decoded data as pixel values (use row stride/width to wrap line)

regionInfoback to summary
private RegionSegmentInformation regionInfo

Region segment information field, 7.4.1

subInputStreamback to summary
private SubInputStream subInputStream
useExtTemplatesback to summary
private boolean useExtTemplates

Generic region segment flags, 7.4.6.2

Constructor Detail

GenericRegionback to summary
public GenericRegion()
GenericRegionback to summary
public GenericRegion(final SubInputStream subInputStream)

Method Detail

computeSegmentDataStructureback to summary
private void computeSegmentDataStructure() throws IOException
copyLineAboveback to summary
private void copyLineAbove(final int lineNumber)

Each pixel gets the value from the corresponding pixel of the row above. Line 0 cannot get copied values (source will be -1, doesn't exist).

Parameters
lineNumber:int

- Coordinate of the row that should be set.

decodeLineback to summary
private void decodeLine(final int lineNumber, final int width, final int rowStride, final int paddedWidth) throws IOException
decodeSLTPback to summary
private int decodeSLTP() throws IOException
decodeTemplate0aback to summary
private void decodeTemplate0a(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx) throws IOException
decodeTemplate0bback to summary
private void decodeTemplate0b(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx) throws IOException
decodeTemplate1back to summary
private void decodeTemplate1(final int lineNumber, int width, final int rowStride, final int paddedWidth, int byteIndex, int idx) throws IOException
decodeTemplate2back to summary
private void decodeTemplate2(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx) throws IOException
decodeTemplate3back to summary
private void decodeTemplate3(final int lineNumber, final int width, final int rowStride, final int paddedWidth, int byteIndex, int idx) throws IOException
getGbAtXback to summary
protected short[] getGbAtX()
getGbAtYback to summary
protected short[] getGbAtY()
getGbTemplateback to summary
protected byte getGbTemplate()
getPixelback to summary
private byte getPixel(final int x, final int y) throws IOException
getRegionBitmapback to summary
public Bitmap getRegionBitmap() throws IOException

Implements org.apache.pdfbox.jbig2.Region.getRegionBitmap.

The procedure is described in 6.2.5.7, page 17.

Returns:Bitmap

The decoded Bitmap of this region.

Exceptions
IOException:

Doc from org.apache.pdfbox.jbig2.Region.getRegionBitmap.

if an underlying IO operation fails

getRegionInfoback to summary
public RegionSegmentInformation getRegionInfo()

Implements org.apache.pdfbox.jbig2.Region.getRegionInfo.

Doc from org.apache.pdfbox.jbig2.Region.getRegionInfo.

Simply returns the RegionSegmentInformation.

Returns:RegionSegmentInformation

The RegionSegmentInformation.

initback to summary
public void init(final SegmentHeader header, final SubInputStream sis) throws InvalidHeaderValueException, IOException

Implements org.apache.pdfbox.jbig2.SegmentData.init.

Doc from org.apache.pdfbox.jbig2.SegmentData.init.

Parse the stream and read information of header.

Parameters
header:SegmentHeader

- The segments' header (to make referred-to segments available in data part).

sis:SubInputStream

- Wrapped ImageInputStream into SubInputStream.

Exceptions
InvalidHeaderValueException:
if the segment header value is invalid
IOException:
if an underlying IO operation fails
isMMREncodedback to summary
protected boolean isMMREncoded()
isTPGDonback to summary
protected boolean isTPGDon()
overrideAtTemplate0aback to summary
private int overrideAtTemplate0a(int context, final int x, final int y, final int result, final int minorX, final int toShift) throws IOException
overrideAtTemplate0bback to summary
private int overrideAtTemplate0b(int context, final int x, final int y, final int result, final int minorX, final int toShift) throws IOException
overrideAtTemplate1back to summary
private int overrideAtTemplate1(int context, final int x, final int y, final int result, final int minorX) throws IOException
overrideAtTemplate2back to summary
private int overrideAtTemplate2(int context, final int x, final int y, final int result, final int minorX) throws IOException
overrideAtTemplate3back to summary
private int overrideAtTemplate3(int context, final int x, final int y, final int result, final int minorX) throws IOException
parseHeaderback to summary
private void parseHeader() throws IOException, InvalidHeaderValueException
readGbAtPixelsback to summary
private void readGbAtPixels(final int amountOfGbAt) throws IOException
resetBitmapback to summary
protected void resetBitmap()

Simply sets the memory-critical bitmap of this region to null.

setOverrideFlagback to summary
private void setOverrideFlag(final int index)
setParametersback to summary
protected void setParameters(final boolean isMMREncoded, final long dataOffset, final long dataLength, final int gbh, final int gbw)

Used by SymbolDictionary.

Parameters
isMMREncoded:boolean

the data is MMR encoded

dataOffset:long

the offset

dataLength:long

the length of the data

gbh:int

bitmap height

gbw:int

bitmap width

setParametersback to summary
protected void setParameters(final boolean isMMREncoded, final byte sdTemplate, final boolean isTPGDon, final boolean useSkip, final short[] sdATX, final short[] sdATY, final int symWidth, final int hcHeight, final CX cx, final ArithmeticDecoder arithmeticDecoder)
Parameters
isMMREncoded:boolean

the data is MMR encoded

sdTemplate:byte

sd template

isTPGDon:boolean

is TPGDon

useSkip:boolean

use skip

sdATX:short[]

x values gbA pixels

sdATY:short[]

y values gbA pixels

symWidth:int

bitmap width

hcHeight:int

bitmap height

cx:CX

context for the arithmetic decoder

arithmeticDecoder:ArithmeticDecoder

the arithmetic decode to be used Used by SymbolDictionary.

setParametersback to summary
protected void setParameters(final boolean isMMREncoded, final long dataOffset, final long dataLength, final int gbh, final int gbw, final byte gbTemplate, final boolean isTPGDon, final boolean useSkip, final short[] gbAtX, final short[] gbAtY)

Used by PatternDictionary and HalftoneRegion.

Parameters
isMMREncoded:boolean

the data is MMR encoded

dataOffset:long

the offset

dataLength:long

the length of the data

gbh:int

bitmap height

gbw:int

bitmap width

gbTemplate:byte

gb template

isTPGDon:boolean

is TPGDon

useSkip:boolean

use skip

gbAtX:short[]

x values of gbA pixels

gbAtY:short[]

y values of gbA pixels

updateOverrideFlagsback to summary
private void updateOverrideFlags()
useExtTemplatesback to summary
protected boolean useExtTemplates()