Documentation ¶
Overview ¶
Package document provides jbig2 encoding primitives used for encoding and decoding purpose.
Index ¶
- type Document
- func (d *Document) AddClassifiedPage(bm *bitmap.Bitmap, method classer.Method) (err error)
- func (d *Document) AddGenericPage(bm *bitmap.Bitmap, duplicateLineRemoval bool) (err error)
- func (d *Document) Encode() (data []byte, err error)
- func (d *Document) GetGlobalSegment(i int) (*segments.Header, error)
- func (d *Document) GetNumberOfPages() (uint32, error)
- func (d *Document) GetPage(pageNumber int) (segments.Pager, error)
- type EncodingMethod
- type Globals
- type Page
- func (p *Page) AddEndOfPageSegment()
- func (p *Page) AddGenericRegion(bm *bitmap.Bitmap, xloc, yloc, template int, tp segments.Type, ...) error
- func (p *Page) AddPageInformationSegment()
- func (p *Page) Encode(w writer.BinaryWriter) (n int, err error)
- func (p *Page) GetBitmap() (bm *bitmap.Bitmap, err error)
- func (p *Page) GetHeight() (int, error)
- func (p *Page) GetResolutionX() (int, error)
- func (p *Page) GetResolutionY() (int, error)
- func (p *Page) GetSegment(number int) (*segments.Header, error)
- func (p *Page) GetWidth() (int, error)
- func (p *Page) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Document ¶
type Document struct { // Pages contains all pages of this document. Pages map[int]*Page // NumberOfPagesUnknown defines if the amout of the pages is known. NumberOfPagesUnknown bool // NumberOfPages - D.4.3 - Number of pages field (4 bytes). Only presented if NumberOfPagesUnknown is true. NumberOfPages uint32 // GBUseExtTemplate defines wether extended Template is used. GBUseExtTemplate bool // SubInputStream is the source data stream wrapped into a SubInputStream. InputStream reader.StreamReader // GlobalSegments contains all segments that aren't associated with a page. GlobalSegments *Globals // OrganizationType is the document segment organization. OrganizationType segments.OrganizationType // Encoder variables // Classer is the document encoding classifier. Classer *classer.Classer // XRes and YRes are the PPI for the x and y direction. XRes, YRes int // FullHeaders is a flag that defines if the encoder should produce full JBIG2 files. FullHeaders bool // CurrentSegmentNumber current symbol number. CurrentSegmentNumber uint32 // AverageTemplates are the grayed templates. AverageTemplates *bitmap.Bitmaps BaseIndexes []int Refinement bool RefineLevel int EncodeGlobals bool // contains filtered or unexported fields }
Document is the jbig2 document model containing pages and global segments. By creating new document with method New or NewWithGlobals all the jbig2 encoded data segment headers are decoded. In order to decode whole document, all of it's pages should be decoded using GetBitmap method. PDF encoded documents should contains only one Page with the number 1.
func DecodeDocument ¶
func DecodeDocument(input reader.StreamReader, globals *Globals) (*Document, error)
DecodeDocument decodes provided document based on the provided 'input' data stream and with optional Global defined segments 'globals'.
func InitEncodeDocument ¶
InitEncodeDocument initializes the jbig2 document for the encoding process.
func (*Document) AddClassifiedPage ¶
AddClassifiedPage adds the bitmap page with a classification 'method'.
func (*Document) AddGenericPage ¶
AddGenericPage creates the jbig2 page based on the provided bitmap. The data provided
func (*Document) GetGlobalSegment ¶
GetGlobalSegment implements segments.Documenter interface.
func (*Document) GetNumberOfPages ¶
GetNumberOfPages gets the amount of Pages in the given document.
type EncodingMethod ¶
type EncodingMethod int
EncodingMethod defines the method of encoding for given page,
const ( GenericEM EncodingMethod = iota CorrelationEM RankHausEM )
enums that defines encoding method.
type Globals ¶
Globals store segments that aren't associated to a page. If the data is embedded in another format, for example PDF, this segments might be stored separately in the file. These segments will be decoded on demand, all results are stored in the document.
func (*Globals) AddSegment ¶
AddSegment adds the segment to the globals store.
func (*Globals) GetSegment ¶
GetSegment gets the global segment header.
func (*Globals) GetSegmentByIndex ¶
GetSegmentByIndex gets segments header by 'index' in the Globals.
type Page ¶
type Page struct { // Segments relation of the page number to their structures. Segments []*segments.Header // PageNumber defines this page number. PageNumber int // Bitmap represents the page image. Bitmap *bitmap.Bitmap // Page parameters FinalHeight int FinalWidth int ResolutionX int ResolutionY int IsLossless bool // Document is a relation to page's document Document *Document // FirstSegmentNumber defines first segment number for given page FirstSegmentNumber int // EncodingMethod defines EncodingMethod EncodingMethod }
Page represents JBIG2 Page structure. It contains all the included segments header definitions mapped to their number relation to the document and the resultant page bitmap. NOTE: page numeration starts from 1 and the association to 0'th page means the segments are associated to global segments.
func (*Page) AddEndOfPageSegment ¶
func (p *Page) AddEndOfPageSegment()
AddEndOfPageSegment adds the end of page segment.
func (*Page) AddGenericRegion ¶
func (p *Page) AddGenericRegion(bm *bitmap.Bitmap, xloc, yloc, template int, tp segments.Type, duplicateLineRemoval bool) error
AddGenericRegion adds the generic region to the page context. 'bm' - bitmap containing data to encode 'xloc' - x location of the generic region 'yloc' - y location of the generic region 'template' - generic region template 'tp' - is the generic region type 'duplicateLineRemoval' - is the flag that defines if the generic region segment should remove duplicated lines
func (*Page) AddPageInformationSegment ¶
func (p *Page) AddPageInformationSegment()
AddPageInformationSegment adds the page information segment to the page segments.
func (*Page) Encode ¶
func (p *Page) Encode(w writer.BinaryWriter) (n int, err error)
Encode encodes segments into provided 'w' writer.
func (*Page) GetResolutionX ¶
GetResolutionX gets the 'x' resolution of the page.
func (*Page) GetResolutionY ¶
GetResolutionY gets the 'y' resolution of the page.
func (*Page) GetSegment ¶
GetSegment implements segments.Pager interface.