Class JBIG2Page


  • class JBIG2Page
    extends java.lang.Object
    This class represents a JBIG2 page.
    • 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
    • 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 or null if not available.
      • getPageInformationSegment

        protected SegmentHeader getPageInformationSegment()
        Returns the associated page information segment.
        Returns:
        The associated PageInformation segment or null 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 a Bitmap
        Throws:
        java.io.IOException
        JBIG2Exception
      • 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:
      • 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 object
        newOperator - - The combination operator, specified by actual segment
        Returns:
        the new combination operator
      • add

        protected void add​(SegmentHeader segment)
        Adds a SegmentHeader 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 class java.lang.Object