class JB2Image: public GPEnabled

Main JB2 data structure.

Inheritance:


Public Fields

[more]GString comment
Comment string.

Public Methods

[more] JB2Image()
Null Constructor.
[more]int get_width() const
Returns the width of the image.
[more]int get_height() const
Returns the height of the image.
[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_shape_count() const
Returns the total number of shapes.
[more]JB2Shape* get_shape(int shapeno)
Returns a pointer to shape shapeno.
[more]const JB2Shape* get_shape(int shapeno) const
Returns a constant pointer to shape shapeno.
[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]void compress()
Compresses all shape bitmaps.
[more]unsigned int get_memory_usage() const
Returns the total memory used by the JB2Image.
[more]void set_dimension(int width, int height)
Sets the size of the JB2Image.
[more]int add_shape(const JB2Shape &shape)
Appends a shape to the shape array.
[more]int add_blit(const JB2Blit &blit)
Appends a blit to the blit array.
[more]void encode(ByteStream &bs, int mode=0) const
Encodes the JB2Image into ByteStream bs.
[more]void decode(ByteStream &bs, int mode=0)
Decodes JB2 data from ByteStream bs.


Inherited from GPEnabled:

Public Methods

oGPEnabled& operator=(const GPEnabled & obj)

Protected Fields

ovolatile int count

Protected Methods

ovirtual void destroy()


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.

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.

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_shape_count() const
Returns the total number of shapes. Shape indices range from 0 to get_shape_count()-1.

oJB2Shape* get_shape(int shapeno)
Returns a pointer to shape shapeno. The returned pointer directly points into the shape array. This pointer can be used for reading or writing the shape data.

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

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.

ovoid compress()
Compresses all shape bitmaps. This function reduces the memory required by the JB2Image by calling compress on all shapes bitmaps. This function is best called after decoding a JB2Image, because function get_bitmap can directly use the compressed bitmaps.

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

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.

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

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.

ovoid encode(ByteStream &bs, int mode=0) const
Encodes the JB2Image into ByteStream bs. This function generates the JB2 data stream without any header. Argument mode is reserved for future extensions (such as specifying JBIG2 encoding versus JB2 encoding) and should be left to the default value.

ovoid decode(ByteStream &bs, int mode=0)
Decodes JB2 data from ByteStream bs. This function decodes the image size and populates the shape and blit arrays. Argument mode is reserved for future extensions (such as specifying JBIG2 encoding versus JB2 encoding) and should be left to the default value.

oGString comment
Comment string. This variable holds the optional comment included in JB2 files.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java