Package org.apache.pdfbox.jbig2
Class JBIG2Page
- java.lang.Object
-
- org.apache.pdfbox.jbig2.JBIG2Page
-
class JBIG2Page extends java.lang.Object
This class represents a JBIG2 page.
-
-
Field Summary
Fields Modifier and Type Field Description private JBIG2Document
document
private int
finalHeight
private int
finalWidth
private Bitmap
pageBitmap
The page bitmap that represents the page bufferprivate int
pageNumber
NOTE: page number != segmentList indexprivate int
resolutionX
private int
resolutionY
private java.util.Map<java.lang.Integer,SegmentHeader>
segments
This list contains all segments of this page, sorted by segment number in ascending order.
-
Constructor Summary
Constructors Modifier Constructor Description protected
JBIG2Page(JBIG2Document document, int pageNumber)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
add(SegmentHeader segment)
Adds aSegmentHeader
into the page's segments map.protected void
clearPageData()
Reset memory-critical parts of page.private void
clearSegmentData()
Resets the memory-critical segments to force on-demand-decoding and to avoid holding the segments' bitmap too long.private java.util.ArrayList<SegmentData>
collectPageStripes()
private void
composePageBitmap()
This method composes the segments' bitmaps to a page and stores the page as aBitmap
private int
countRegions()
This method counts the regions segments.private void
createNormalPage(PageInformation pageInformation)
private void
createPage(PageInformation pageInformation)
private void
createStripedPage(PageInformation pageInformation)
private boolean
fitsPage(PageInformation pageInformation, Bitmap regionBitmap)
Check if we have only one region that forms the complete page.protected Bitmap
getBitmap()
This method returns the decoded bitmap if present.private CombinationOperator
getCombinationOperator(PageInformation pi, CombinationOperator newOperator)
This method checks and sets, which combination operator shall be used.protected int
getHeight()
Returns the final height of the page.protected SegmentHeader
getPageInformationSegment()
Returns the associated page information segment.protected int
getResolutionX()
protected int
getResolutionY()
SegmentHeader
getSegment(int number)
This method searches for a segment specified by its number.protected int
getWidth()
java.lang.String
toString()
-
-
-
Field Detail
-
segments
private final java.util.Map<java.lang.Integer,SegmentHeader> segments
This list contains all segments of this page, sorted by segment number in ascending order.
-
pageNumber
private final int pageNumber
NOTE: page number != segmentList index
-
pageBitmap
private Bitmap pageBitmap
The page bitmap that represents the page buffer
-
finalHeight
private int finalHeight
-
finalWidth
private int finalWidth
-
resolutionX
private int resolutionX
-
resolutionY
private int resolutionY
-
document
private final JBIG2Document document
-
-
Constructor Detail
-
JBIG2Page
protected JBIG2Page(JBIG2Document document, int pageNumber)
-
-
Method Detail
-
getSegment
public SegmentHeader getSegment(int number)
This method searches for a segment specified by its number.- Parameters:
number
- - Segment number of the segment to search.- Returns:
- The retrieved
SegmentHeader
ornull
if not available.
-
getPageInformationSegment
protected SegmentHeader getPageInformationSegment()
Returns the associated page information segment.- Returns:
- The associated
PageInformation
segment ornull
if not available.
-
getBitmap
protected Bitmap getBitmap() throws JBIG2Exception, java.io.IOException
This method returns the decoded bitmap if present. Otherwise the page bitmap will be composed before returning the result.- Returns:
- pageBitmap - The result of decoding a page
- Throws:
JBIG2Exception
java.io.IOException
-
composePageBitmap
private void composePageBitmap() throws java.io.IOException, JBIG2Exception
This method composes the segments' bitmaps to a page and stores the page as aBitmap
- Throws:
java.io.IOException
JBIG2Exception
-
createPage
private void createPage(PageInformation pageInformation) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
createNormalPage
private void createNormalPage(PageInformation pageInformation) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
fitsPage
private boolean fitsPage(PageInformation pageInformation, Bitmap regionBitmap)
Check if we have only one region that forms the complete page. If the dimension equals the page's dimension set the region's bitmap as the page's bitmap. Otherwise we have to blit the smaller region's bitmap into the page's bitmap (see Issue 6).- Parameters:
pageInformation
-regionBitmap
-- Returns:
-
createStripedPage
private void createStripedPage(PageInformation pageInformation) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOException
IntegerMaxValueException
InvalidHeaderValueException
-
collectPageStripes
private java.util.ArrayList<SegmentData> collectPageStripes()
-
countRegions
private int countRegions()
This method counts the regions segments. If there is only one region, the bitmap of this segment is equal to the page bitmap and blitting is not necessary.- Returns:
- Amount of regions.
-
getCombinationOperator
private CombinationOperator getCombinationOperator(PageInformation pi, CombinationOperator newOperator)
This method checks and sets, which combination operator shall be used.- Parameters:
pi
- -PageInformation
objectnewOperator
- - The combination operator, specified by actual segment- Returns:
- the new combination operator
-
add
protected void add(SegmentHeader segment)
Adds aSegmentHeader
into the page's segments map.- Parameters:
segment
- - The segment to be added.
-
clearSegmentData
private void clearSegmentData()
Resets the memory-critical segments to force on-demand-decoding and to avoid holding the segments' bitmap too long.
-
clearPageData
protected void clearPageData()
Reset memory-critical parts of page.
-
getHeight
protected int getHeight() throws java.io.IOException, JBIG2Exception
Returns the final height of the page.- Returns:
- The final height of the page.
- Throws:
java.io.IOException
JBIG2Exception
-
getWidth
protected int getWidth()
-
getResolutionX
protected int getResolutionX()
-
getResolutionY
protected int getResolutionY()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-