Package org.apache.pdfbox.jbig2
Class JBIG2Page
- java.lang.Object
-
- org.apache.pdfbox.jbig2.JBIG2Page
-
class JBIG2Page extends java.lang.ObjectThis class represents a JBIG2 page.
-
-
Field Summary
Fields Modifier and Type Field Description private JBIG2Documentdocumentprivate intfinalHeightprivate intfinalWidthprivate BitmappageBitmapThe page bitmap that represents the page bufferprivate intpageNumberNOTE: page number != segmentList indexprivate intresolutionXprivate intresolutionYprivate java.util.Map<java.lang.Integer,SegmentHeader>segmentsThis list contains all segments of this page, sorted by segment number in ascending order.
-
Constructor Summary
Constructors Modifier Constructor Description protectedJBIG2Page(JBIG2Document document, int pageNumber)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadd(SegmentHeader segment)Adds aSegmentHeaderinto the page's segments map.protected voidclearPageData()Reset memory-critical parts of page.private voidclearSegmentData()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 voidcomposePageBitmap()This method composes the segments' bitmaps to a page and stores the page as aBitmapprivate intcountRegions()This method counts the regions segments.private voidcreateNormalPage(PageInformation pageInformation)private voidcreatePage(PageInformation pageInformation)private voidcreateStripedPage(PageInformation pageInformation)private booleanfitsPage(PageInformation pageInformation, Bitmap regionBitmap)Check if we have only one region that forms the complete page.protected BitmapgetBitmap()This method returns the decoded bitmap if present.private CombinationOperatorgetCombinationOperator(PageInformation pi, CombinationOperator newOperator)This method checks and sets, which combination operator shall be used.protected intgetHeight()Returns the final height of the page.protected SegmentHeadergetPageInformationSegment()Returns the associated page information segment.protected intgetResolutionX()protected intgetResolutionY()SegmentHeadergetSegment(int number)This method searches for a segment specified by its number.protected intgetWidth()java.lang.StringtoString()
-
-
-
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
SegmentHeaderornullif not available.
-
getPageInformationSegment
protected SegmentHeader getPageInformationSegment()
Returns the associated page information segment.- Returns:
- The associated
PageInformationsegment ornullif 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:
JBIG2Exceptionjava.io.IOException
-
composePageBitmap
private void composePageBitmap() throws java.io.IOException, JBIG2ExceptionThis method composes the segments' bitmaps to a page and stores the page as aBitmap- Throws:
java.io.IOExceptionJBIG2Exception
-
createPage
private void createPage(PageInformation pageInformation) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOExceptionIntegerMaxValueExceptionInvalidHeaderValueException
-
createNormalPage
private void createNormalPage(PageInformation pageInformation) throws java.io.IOException, IntegerMaxValueException, InvalidHeaderValueException
- Throws:
java.io.IOExceptionIntegerMaxValueExceptionInvalidHeaderValueException
-
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.IOExceptionIntegerMaxValueExceptionInvalidHeaderValueException
-
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- -PageInformationobjectnewOperator- - The combination operator, specified by actual segment- Returns:
- the new combination operator
-
add
protected void add(SegmentHeader segment)
Adds aSegmentHeaderinto 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, JBIG2ExceptionReturns the final height of the page.- Returns:
- The final height of the page.
- Throws:
java.io.IOExceptionJBIG2Exception
-
getWidth
protected int getWidth()
-
getResolutionX
protected int getResolutionX()
-
getResolutionY
protected int getResolutionY()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-