jbig2

package
v0.0.0-...-fb73569 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package jbig2 provides the jbig2 standard image Encoder and Decoder. All the comments reference to the 'ISO/IEC 14992 INFORMATION TECHNOLOGY - CODED REPRESENTATION OF PICTURE AND AUDIO INFORMATION - LOSSY/LOSSLESS CODING OF BI-LEVEL IMAGES JBIG commitee 1999 July 16' document. The document is available and can be downloaded at: 'https://github.com/agl/jbig2enc/blob/master/fcd14492.pdf'

The decoder was based on the 'Apache PDFBox JBIG2 Java plugin' which can be found at: 'https://github.com/apache/pdfbox-jbig2'.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoGlobalsYet  = errors.New("no global segment added yet")
	ErrNoGlobalFound = errors.New("no global segment found")
)

Common errors definitions.

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 ammount 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.Reader

	// GlobalSegments contains all segments that aren't associated with a page.
	GlobalSegments Globals

	// OrganisationType is the document segment organization.
	OrganizationType segments.OrganizationType
	// contains filtered or unexported fields
}

Document is the jbig2 document model containing pages and global segments. By creating new document with method NewDocument or NewDocumentWithGlobals 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 NewDocument

func NewDocument(data []byte) (*Document, error)

NewDocument creates new Document for the 'data' byte slice.

func NewDocumentWithGlobals

func NewDocumentWithGlobals(data []byte, globals Globals) (*Document, error)

NewDocumentWithGlobals creates new Document for the provided encoded 'data' byte slice and the 'globals' Globals.

func (*Document) GetGlobalSegment

func (d *Document) GetGlobalSegment(i int) *segments.Header

GetGlobalSegment implements segments.Documenter interface.

func (*Document) GetNumberOfPages

func (d *Document) GetNumberOfPages() (uint32, error)

GetNumberOfPages gets the amount of Pages in the given document.

func (*Document) GetPage

func (d *Document) GetPage(pageNumber int) (segments.Pager, error)

GetPage implements segments.Documenter interface. NOTE: in order to decode all document images, get page by page (page numeration starts from '1') and decode them by calling 'GetBitmap' method.

type Globals

type Globals map[int]*segments.Header

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. This segments will be decoded on demand, all results are stored in the document.

func (Globals) AddSegment

func (g Globals) AddSegment(segmentNumber int, segment *segments.Header)

AddSegment adds the segment to the globals store.

func (Globals) GetSegment

func (g Globals) GetSegment(segmentNumber int) (*segments.Header, error)

GetSegment gets the global segment header.

type Page

type Page struct {
	// Segments relation of the page number to their structures.
	Segments map[int]*segments.Header

	// PageNumber defines page number.
	// NOTE: page numeration starts from 1.
	PageNumber int

	// Bitmap represents the page image.
	Bitmap *bitmap.Bitmap

	FinalHeight int
	FinalWidth  int
	ResolutionX int
	ResolutionY int

	// Document is a relation to page's document
	Document *Document
}

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.

func (*Page) GetBitmap

func (p *Page) GetBitmap() (bm *bitmap.Bitmap, err error)

GetBitmap implements segments.Pager interface.

func (*Page) GetSegment

func (p *Page) GetSegment(number int) *segments.Header

GetSegment implements segments.Pager interface.

func (*Page) String

func (p *Page) String() string

String implements Stringer interface.

Directories

Path Synopsis
Package bitmap contains the bitmap data container for the binary images used when decoding the jbig2 encoded images.
Package bitmap contains the bitmap data container for the binary images used when decoding the jbig2 encoded images.
decoder
arithmetic
Package arithmetic contains the jbig2 arithmetic decoder used to decode the jbig2 encoded segments.
Package arithmetic contains the jbig2 arithmetic decoder used to decode the jbig2 encoded segments.
huffman
Package huffman contains jbig2 huffman tables used to decode jbig2 encoded data segments.
Package huffman contains jbig2 huffman tables used to decode jbig2 encoded data segments.
mmr
Package mmr contains the jbig2 mmr decoder used to decode jbig2 encoded data segments.
Package mmr contains the jbig2 mmr decoder used to decode jbig2 encoded data segments.
Package encoder contains jbig2 encoder structures.
Package encoder contains jbig2 encoder structures.
Package reader provides the stream readers used by the jbig2 segments decoder.
Package reader provides the stream readers used by the jbig2 segments decoder.
Package segments provides jbig2 segments models used in the jbig2 document decoding process.
Package segments provides jbig2 segments models used in the jbig2 document decoding process.
Package tests contains the tests and benchmarks for the JBIG2 decoder.
Package tests contains the tests and benchmarks for the JBIG2 decoder.
Package writer contains the data writer that implements io.Writer, io.ByteWriter and allows to write single bits.
Package writer contains the data writer that implements io.Writer, io.ByteWriter and allows to write single bits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL