class DjVuImage: public DjVuPort

Main DjVu Image data structure.

Inheritance:


Public Methods

[more] DjVuFileCache(int max_size=5*2*1024*1024)
Constructs the DjVuFileCache
[more]void del_file(const DjVuFile * file)
Removes file file from the cache
[more]void add_file(const GP<DjVuFile> & file)
Adds the given file to the cache.
[more]void clear(void)
Clears the cache.
[more]void set_max_size(int max_size)
Sets new maximum size.
[more]int get_max_size(void) const
Returns the maximum allowed size of the cache.
[more]void enable(bool en)
Enables or disables the cache.
[more]bool is_enabled(void) const
Returns TRUE if the cache is enabled, FALSE otherwise.

Public

[more] Construction.

[more] DjVuImage(void)
Constructs an empty DjVu image.
[more]void connect(const GP<DjVuFile> & file)
Connects this DjVuImage to the passed DjVuFile.

[more] Components.

[more]GP<DjVuInfo> get_info() const
Returns a pointer to a DjVu information component.
[more]GP<IW44Image> get_bg44() const
Returns a pointer to the IW44 encoded background component of a DjVu image.
[more]GP<GPixmap> get_bgpm() const
Returns a pointer to the raw background component of a DjVu image.
[more]GP<JB2Image> get_fgjb() const
Returns a pointer to the mask of the foreground component of a DjVu image.
[more]GP<GPixmap> get_fgpm() const
Returns a pointer to the colors of the foreground component of a DjVu image.
[more]GP<DjVuPalette> get_fgbc() const
Returns a pointer to a palette object containing colors for the foreground components of a DjVu image.
[more]GP<ByteStream> get_anno() const
Returns a pointer to a ByteStream containing all the annotation chunks collected so far for this image.
[more]GP<ByteStream> get_text() const
Returns a pointer to a ByteStream containing all the hidden text.

[more] New style decoding.

[more]bool wait_for_complete_decode(void)
The decoder is now started when the image is created by function get_page in DjVuDocument.

[more] Old style decoding (backward compatibility).

[more]void decode(ByteStream & str, DjVuInterface *notifier=0)
This function is here for backward compatibility.

[more] Utilities

[more]int get_width() const
Returns the width of the DjVu image.
[more]int get_height() const
Returns the height of the DjVu image.
[more]int get_version() const
Returns the format version the DjVu data.
[more]int get_dpi() const
Returns the resolution of the DjVu image.
[more]int get_rounded_dpi() const
Same as get_dpi() but instead of precise value returns the closest "standard" one: 25, 50, 75, 100, 150, 300, 600.
[more]double get_gamma() const
Returns the gamma coefficient of the display for which the image was designed.
[more]GString get_mimetype() const
Returns a MIME type string describing the DjVu data.
[more]GString get_short_description() const
Returns a short string describing the DjVu image.
[more]GString get_long_description() const
Returns a verbose description of the DjVu image.
[more]GP<DjVuFile> get_djvu_file(void) const
Returns pointer to DjVuFile which contains this image in compressed form.

[more] Checking for legal DjVu files.

[more]int is_legal_photo() const
This function returns true if this object contains a well formed Photo DjVu Image.
[more]int is_legal_bilevel() const
This function returns true if this object contains a well formed Bilevel DjVu Image.
[more]int is_legal_compound() const
This function returns true if this object contains a well formed Compound DjVu Image.

[more] Rendering.

[more]GP<GPixmap> get_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the image and returns a color pixel image.
[more]GP<GBitmap> get_bitmap(const GRect &rect, const GRect &all, int align = 1) const
Renders the mask of the foreground layer of the DjVu image.
[more]GP<GPixmap> get_bg_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the background layer of the DjVu image.
[more]GP<GPixmap> get_fg_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the foreground layer of the DjVu image.

Protected Methods

[more]virtual void file_added(const GP<DjVuFile> & file)
This function is called right after the given file has been added to the cache for management.
[more]virtual void file_deleted(const GP<DjVuFile> & file)
This function is called when the given file is no longer managed by the cache.
[more]virtual void file_cleared(const GP<DjVuFile> & file)
This function is called when after the cache decides to get rid of the file.


Inherited from DjVuPort:

Public Methods

ostatic DjVuPortcaster* get_portcaster(void)
oDjVuPort& operator=(const DjVuPort & port)
ovirtual bool inherits(const char * class_name) const

Public

Notifications.

[more]virtual GURL id_to_url(const DjVuPort * source, const char * id)
This request is issued to request translation of the ID, used in an DjVu INCL chunk to a URL, which may be used to request data associated with included file.
[more]virtual GPBase id_to_file(const DjVuPort * source, const char * id)
This request is used to get a file corresponding to the given ID.
[more]virtual GP<DataPool> request_data(const DjVuPort * source, const GURL & url)
This request is issued when decoder needs additional data for decoding.
[more]virtual bool notify_error(const DjVuPort * source, const char * msg)
This notification is sent when an error occurs and the error message should be shown to the user.
[more]virtual bool notify_status(const DjVuPort * source, const char * msg)
This notification is sent to update the decoding status.
[more]virtual void notify_redisplay(const class DjVuImage * source)
This notification is sent by DjVuImage when it should be redrawn.
[more]virtual void notify_relayout(const class DjVuImage * source)
This notification is sent by \ref{DjVuImage} when its geometry has been changed as a result of decoding.
[more]virtual void notify_chunk_done(const DjVuPort * source, const char * name)
This notification is sent when a new chunk has been decoded.
[more]virtual void notify_file_flags_changed(const class DjVuFile * source, long set_mask, long clr_mask)
This notification is sent after the DjVuFile flags have been changed.
[more]virtual void notify_doc_flags_changed(const class DjVuDocument * source, long set_mask, long clr_mask)
This notification is sent after the DjVuDocument flags have been changed.
[more]virtual void notify_decode_progress(const DjVuPort * source, float done)
This notification is sent from time to time while decoding is in progress.
[more]enum ErrorRecoveryAction
This is the standard types for defining what to do in case of errors.


Inherited from GPEnabled:

Public Methods

oint get_count(void) const

Protected Fields

ovolatile int count


Documentation

Main DjVu Image data structure. This class defines the internal representation of a DjVu image. This representation consists of a few pointers referencing the various components of the DjVu image. These components are created and populated by the decoding function. The rendering functions then can use the available components to compute a pixel representation of the desired segment of the DjVu image.
o DjVuFileCache(int max_size=5*2*1024*1024)
Constructs the DjVuFileCache
Parameters:
max_size - Maximum allowed size of the cache in bytes.

ovoid del_file(const DjVuFile * file)
Removes file file from the cache

ovoid add_file(const GP<DjVuFile> & file)
Adds the given file to the cache. It it's already there, its timestamp will be refreshed.

ovoid clear(void)
Clears the cache. All items will be deleted.

ovoid set_max_size(int max_size)
Sets new maximum size. If the total size of all items in the cache is greater than max_size, the cache will be deleting the oldest items until the size is OK.

oint get_max_size(void) const
Returns the maximum allowed size of the cache.

ovoid enable(bool en)
Enables or disables the cache. See is_enabled() for details
Parameters:
en - - If en is TRUE, the cache will be enabled. Otherwise it will be disabled.

obool is_enabled(void) const
Returns TRUE if the cache is enabled, FALSE otherwise. When a cache is disabled, add_file(), and del_file() do nothing. But the maximum size is preserved inside the class so that next time the cache is enabled, it will be configured the same way. Clearly this "enable/disable" thing is for convenience only. One could easily simulate this behavior by setting the maximum size of the cache to ZERO.

ovirtual void file_added(const GP<DjVuFile> & file)
This function is called right after the given file has been added to the cache for management.

ovirtual void file_deleted(const GP<DjVuFile> & file)
This function is called when the given file is no longer managed by the cache.

ovirtual void file_cleared(const GP<DjVuFile> & file)
This function is called when after the cache decides to get rid of the file.

o Construction.

o DjVuImage(void)
Constructs an empty DjVu image. After the image has been constructed, it may be connected to an existing DjVuFile or left as is.

In the former case DjVuImage will look for its decoded components (like Sjbz or BG44) by decending the hierarchy of DjVuFiles starting from the one passed to connect().

In the latter case you can use decode() function to decode single-page DjVu documents in the old-style way.

ovoid connect(const GP<DjVuFile> & file)
Connects this DjVuImage to the passed DjVuFile. The DjVuImage will use this DjVuFile to retrieve components necessary for decoding. It will also connect itself to DjVuFile using the communication mechanism provided by DjVuPort and DjVuPortcaster. This will allow it to receive and relay messages and requests generated by the passed DjVuFile and any file included into it.

o Components.

oGP<DjVuInfo> get_info() const
Returns a pointer to a DjVu information component. This function returns a null pointer until the decoder actually processes an "INFO" chunk.

oGP<IW44Image> get_bg44() const
Returns a pointer to the IW44 encoded background component of a DjVu image. This function returns a null pointer until the decoder actually processes an "BG44" chunk.

oGP<GPixmap> get_bgpm() const
Returns a pointer to the raw background component of a DjVu image. The background component is used for JPEG encoded backgrounds. This function returns a null pointer until the decoder actually processes an "BGjp" chunk.

oGP<JB2Image> get_fgjb() const
Returns a pointer to the mask of the foreground component of a DjVu image. The mask of the foreground component is always a JB2 image in this implementation. This function returns a null pointer until the decoder actually processes an "Sjbz" chunk.

oGP<GPixmap> get_fgpm() const
Returns a pointer to the colors of the foreground component of a DjVu image. The mask of the foreground component is always a small pixmap in this implementation. This function returns a null pointer until the decoder actually processes an "FG44" chunk.

oGP<DjVuPalette> get_fgbc() const
Returns a pointer to a palette object containing colors for the foreground components of a DjVu image. These colors are only pertinent with respect to the JB2Image.

oGP<ByteStream> get_anno() const
Returns a pointer to a ByteStream containing all the annotation chunks collected so far for this image. Individual chunks can be retrieved using IFFByteStream. Returns NULL if no chunks have been collected yet.

oGP<ByteStream> get_text() const
Returns a pointer to a ByteStream containing all the hidden text. Returns NULL if no chunks have been collected yet.

o New style decoding.

obool wait_for_complete_decode(void)
The decoder is now started when the image is created by function get_page in DjVuDocument. This function waits until the decoding thread terminates and returns TRUE if the image has been successfully decoded.

o Old style decoding (backward compatibility).

ovoid decode(ByteStream & str, DjVuInterface *notifier=0)
This function is here for backward compatibility. Now, with the introduction of multipage DjVu documents, the decoding is handled by DjVuFile and DjVuDocument classes. For single page documents though, we still have this wrapper.

o Utilities

oint get_width() const
Returns the width of the DjVu image. This function just extracts this information from the DjVu information component. It returns zero if such a component is not yet available.

oint get_height() const
Returns the height of the DjVu image. This function just extracts this information from the DjVu information component. It returns zero if such a component is not yet available.

oint get_version() const
Returns the format version the DjVu data. This function just extracts this information from the DjVu information component. It returns zero if such a component is not yet available. This version number should be compared with the DjVu version constants.

oint get_dpi() const
Returns the resolution of the DjVu image. This information is given in pixels per 2.54 cm. Display programs can use this information to determine the natural magnification to use for rendering a DjVu image.

oint get_rounded_dpi() const
Same as get_dpi() but instead of precise value returns the closest "standard" one: 25, 50, 75, 100, 150, 300, 600. If dpi is greater than 700, it's returned as is.

odouble get_gamma() const
Returns the gamma coefficient of the display for which the image was designed. The rendering functions can use this information in order to perform color correction for the intended display device.

oGString get_mimetype() const
Returns a MIME type string describing the DjVu data. This information is auto-sensed by the decoder. The MIME type can be "image/djvu" or "image/iw44" depending on the data stream.

oGString get_short_description() const
Returns a short string describing the DjVu image. Example: "2500x3223 in 23.1 Kb".

oGString get_long_description() const
Returns a verbose description of the DjVu image. This description lists all the chunks with their size and a brief comment, as shown in the following example.
      DJVU Image (2325x3156) version 17:
       0.0 Kb   'INFO'  Page information.
       17.3 Kb  'Sjbz'  JB2 foreground mask (2325x3156)
       2.5 Kb   'BG44'  IW44 background (775x1052)
       1.0 Kb   'FG44'  IW44 foreground colors (194x263)
       3.0 Kb   'BG44'  IW44 background (part 2).
       0.9 Kb   'BG44'  IW44 background (part 3).
       7.1 Kb   'BG44'  IW44 background (part 4).
      Compression ratio: 676 (31.8 Kb)
      

oGP<DjVuFile> get_djvu_file(void) const
Returns pointer to DjVuFile which contains this image in compressed form.

o Checking for legal DjVu files.

oint is_legal_photo() const
This function returns true if this object contains a well formed Photo DjVu Image. Calling function get_pixmap on a well formed photo image should always return a non zero value. Note that function get_pixmap works as soon as sufficient information is present, regardless of the fact that the image follows the rules or not.

oint is_legal_bilevel() const
This function returns true if this object contains a well formed Bilevel DjVu Image. Calling function get_bitmap on a well formed bilevel image should always return a non zero value. Note that function get_bitmap works as soon as a foreground mask component is present, regardless of the fact that the image follows the rules or not.

oint is_legal_compound() const
This function returns true if this object contains a well formed Compound DjVu Image. Calling function get_bitmap or get_pixmap on a well formed compound DjVu image should always return a non zero value. Note that functions get_bitmap or get_pixmap works as soon as sufficient information is present, regardless of the fact that the image follows the rules or not.

o Rendering.
All these functions take two rectangles as argument. Conceptually, these function first render the whole image into a rectangular area defined by rectangle all. The relation between this rectangle and the image size define the appropriate scaling. The rendering function then extract the subrectangle rect and return the corresponding pixels as a GPixmap or GBitmap object. The actual implementation performs these two operation simultaneously for obvious efficiency reasons. The best rendering speed is achieved by making sure that the size of rectangle all and the size of the DjVu image are related by an integer ratio.

oGP<GPixmap> get_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the image and returns a color pixel image. Rectangles rect and all are used as explained above. Color correction is performed according to argument gamma, which represents the gamma coefficient of the display device on which the pixmap will be rendered. The default value, zero, means that no color correction should be performed. This function returns a null pointer if there is not enough information in the DjVu image to properly render the desired image.

oGP<GBitmap> get_bitmap(const GRect &rect, const GRect &all, int align = 1) const
Renders the mask of the foreground layer of the DjVu image. This functions is a wrapper for get_bitmap. 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. This function returns a null pointer if there is not enough information in the DjVu image to properly render the desired image.

oGP<GPixmap> get_bg_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the background layer of the DjVu image. Rectangles rect and all are used as explained above. Color correction is performed according to argument gamma, which represents the gamma coefficient of the display device on which the pixmap will be rendered. The default value, zero, means that no color correction should be performed. This function returns a null pointer if there is not enough information in the DjVu image to properly render the desired image.

oGP<GPixmap> get_fg_pixmap(const GRect &rect, const GRect &all, double gamma=0) const
Renders the foreground layer of the DjVu image. Rectangles rect and all are used as explained above. Color correction is performed according to argument gamma, which represents the gamma coefficient of the display device on which the pixmap will be rendered. The default value, zero, means that no color correction should be performed. This function returns a null pointer if there is not enough information in the DjVu image to properly render the desired image.


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.