class JB2Image: public JB2Dict

Main JB2 data structure.

Inheritance:


Public Fields

[more]bool reproduce_old_bug
Reproduces a old bug.

Public Methods

[more] JB2Image()
Null Constructor.
[more]void init()
Resets the JB2Image object.
[more]int get_width() const
Returns the width of the image.
[more]int get_height() const
Returns the height of the image.
[more]void set_dimension(int width, int height)
Sets the size of the JB2Image.
[more]GP<GBitmap> get_bitmap(int subsample = 1, int align = 1) const
Renders an anti-aliased gray level image.
[more]GP<GBitmap> get_bitmap(const GRect &rect, int subsample=1, int align=1, int dispy=0) const
Renders an anti-aliased gray level sub-image.
[more]int get_blit_count() const
Returns the total number of blits.
[more]JB2Blit* get_blit(int blitno)
Returns a pointer to blit blitno.
[more]const JB2Blit* get_blit(int blitno) const
Returns a constant pointer to blit blitno.
[more]int add_blit(const JB2Blit &blit)
Appends a blit to the blit array.
[more]unsigned int get_memory_usage() const
Returns the total memory used by the JB2Image.
[more]void encode(ByteStream &bs) const
Encodes the JB2Image into ByteStream bs.
[more]void decode(ByteStream &bs, JB2DecoderCallback *cb=0, void *arg=0)
Decodes JB2 data from ByteStream bs.


Inherited from JB2Dict:

Public Fields

oGString comment

Public Methods

oGP<JB2Dict> get_inherited_dict() const
oint get_inherited_shape_count() const
ovoid set_inherited_dict(GP<JB2Dict> dict)
oint get_shape_count() const
oJB2Shape* get_shape(int shapeno)
oconst JB2Shape* get_shape(int shapeno) const
oint add_shape(const JB2Shape &shape)
ovoid compress()


Inherited from GPEnabled:

Public Methods

oGPEnabled& operator=(const GPEnabled & obj)
oint get_count(void) const

Protected Fields

ovolatile int count


Documentation

Main JB2 data structure. Each JB2Image consists of an array of shapes and an array of blits. These arrays can be populated by hand using functions add_shape and add_blit, or by decoding JB2 data using function decode. You can then use function get_bitmap to render anti-aliased images, or use function encode to generate JB2 data.
o JB2Image()
Null Constructor. Constructs an empty JB2Image object. You can then call the decoding function decode. You can also manually set the image size using set_dimension and populate the shape and blit arrays using add_shape and add_blit.

ovoid init()
Resets the JB2Image object. This function reinitializes both the shape and the blit arrays. All allocated memory is freed.

oint get_width() const
Returns the width of the image. This is the width value previously set with set_dimension.

oint get_height() const
Returns the height of the image. This is the height value previously set with set_dimension.

ovoid set_dimension(int width, int height)
Sets the size of the JB2Image. This function can be called at any time. The corresponding width and the height are stored in the JB2 file.

oGP<GBitmap> get_bitmap(int subsample = 1, int align = 1) const
Renders an anti-aliased gray level image. This function renders the JB2Image as a bilevel or gray level image. Argument subsample specifies the desired subsampling ratio in range 1 to 15. The returned image uses 1+subsample^2 gray levels for representing anti-aliased edges. Argument align specified the alignment of the rows of the returned images. Setting align to 4, for instance, will adjust the bitmap border in order to make sure that each row of the returned image starts on a word (four byte) boundary.

oGP<GBitmap> get_bitmap(const GRect &rect, int subsample=1, int align=1, int dispy=0) const
Renders an anti-aliased gray level sub-image. This function renders a segment of the JB2Image as a bilevel or gray level image. Conceptually, this function first renders the full JB2Image with subsampling ratio subsample and then extracts rectangle rect in the subsampled image. Both operations of course are efficiently performed simultaneously. Argument align specified the alignment of the rows of the returned images, as explained above. Argument dispy should remain null.

oint get_blit_count() const
Returns the total number of blits. Blit indices range from 0 to get_blit_count()-1.

oJB2Blit* get_blit(int blitno)
Returns a pointer to blit blitno. The returned pointer directly points into the blit array. This pointer can be used for reading or writing the blit data.

oconst JB2Blit* get_blit(int blitno) const
Returns a constant pointer to blit blitno. The returned pointer directly points into the shape array. This pointer can only be used for reading the shape data.

oint add_blit(const JB2Blit &blit)
Appends a blit to the blit array. This function appends a copy of blit blit to the blit array and returns the subscript of the new blit. The shape subscript blit.shapeno must actually designate an already existing shape.

ounsigned int get_memory_usage() const
Returns the total memory used by the JB2Image. The returned value is expressed in bytes.

ovoid encode(ByteStream &bs) const
Encodes the JB2Image into ByteStream bs. This function generates the JB2 data stream without any header.

ovoid decode(ByteStream &bs, JB2DecoderCallback *cb=0, void *arg=0)
Decodes JB2 data from ByteStream bs. This function decodes the image size and populates the shape and blit arrays. The callback function cb is called when the decoder determines that the ByteStream data requires a shape dictionary which has not been set with set_inherited_dict. The callback receives argument arg and must return a suitable dictionary which will be installed as the inherited dictionary. The callback should return null if no such dictionary is found.

obool reproduce_old_bug
Reproduces a old bug. Setting this flag may be necessary for accurately decoding DjVu files with version smaller than 18. The default value is of couse false.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


DjVu is a trademark of LizardTech, Inc.
All other products mentioned are registered trademarks or trademarks of their respective companies.