Logo Search packages:      
Sourcecode: djvulibre version File versions

DjVuImage Class Reference

#include <DjVuImage.h>

Inheritance diagram for DjVuImage:

DjVuPort GPEnabled

List of all members.

Detailed Description

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.

Definition at line 137 of file DjVuImage.h.


These virtual functions may be overridden by the subclasses of DjVuPort#. They are called by the {DjVuPortcaster} when the port is alive and when there is a route between the source of the notification and this port.

enum  ErrorRecoveryAction { ABORT = 0, SKIP_PAGES = 1, SKIP_CHUNKS = 2, KEEP_ALL = 3 }
virtual GP< DjVuFileid_to_file (const DjVuPort *source, const GUTF8String &id)
virtual GURL id_to_url (const DjVuPort *source, const GUTF8String &id)
virtual void notify_decode_progress (const DjVuPort *source, float done)
virtual void notify_doc_flags_changed (const class DjVuDocument *source, long set_mask, long clr_mask)
virtual bool notify_error (const DjVuPort *source, const GUTF8String &msg)
virtual void notify_file_flags_changed (const class DjVuFile *source, long set_mask, long clr_mask)
virtual void notify_redisplay (const class DjVuImage *source)
virtual void notify_relayout (const class DjVuImage *source)
virtual bool notify_status (const DjVuPort *source, const GUTF8String &msg)
virtual GP< DataPoolrequest_data (const DjVuPort *source, const GURL &url)


static GP< DjVuImagecreate (const GP< DjVuFile > &file)
static GP< DjVuImagecreate (void)
void connect (const GP< DjVuFile > &file)

Public Types

enum  { NOINFO, NOTEXT = 1, NOMAP = 4, NOMETA = 8 }

Public Member Functions

GP< GPixmapget_bg_pixmap (const GRect &rect, int subs=1, double gamma=0) const
GP< GBitmapget_bitmap (const GRect &rect, int subs=1, int align=1) const
int get_count (void) const
GP< GPixmapget_fg_pixmap (const GRect &rect, int subs=1, double gamma=0) const
GP< GPixmapget_pixmap (const GRect &rect, int subs=1, double gamma=0) const
virtual void notify_chunk_done (const DjVuPort *, const GUTF8String &name)
Old style decoding (backward compatibility).

void decode (ByteStream &str, DjVuInterface *notifier=0)

GP< ByteStreamget_anno () const
GP< IW44Imageget_bg44 () const
GP< GPixmapget_bgpm () const
GP< DjVuPalette > get_fgbc () const
GP< JB2Imageget_fgjb () const
GP< GPixmapget_fgpm () const
GP< DjVuInfoget_info () const
GP< ByteStreamget_meta () const
GP< ByteStreamget_text () const
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 all# and rect# should take the any rotation in to effect, 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.

GP< GPixmapget_bg_pixmap (const GRect &rect, const GRect &all, double gamma=0) const
GP< GBitmapget_bitmap (const GRect &rect, const GRect &all, int align=1) const
GP< DjVuAnnoget_decoded_anno ()
GP< GPixmapget_fg_pixmap (const GRect &rect, const GRect &all, double gamma=0) const
GP< GPixmapget_pixmap (const GRect &rect, const GRect &all, double gamma=0) const
int get_rotate () const
void map (int &x, int &y) const
void map (GRect &rect) const
void set_rotate (int count=0)
void unmap (int &x, int &y) const
void unmap (GRect &rect) const

GP< DjVuFileget_djvu_file (void) const
int get_dpi () const
double get_gamma () const
int get_height () const
GUTF8String get_long_description () const
GUTF8String get_mimetype () const
int get_real_height () const
int get_real_width () const
int get_rounded_dpi () const
GUTF8String get_short_description () const
int get_version () const
int get_width () const
GUTF8String get_XML (void) const
 Get a DjVuXML object tag and map tag.
GUTF8String get_XML (const GURL &doc_url, const int flags=0) const
 Get a DjVuXML object tag and map tag.
void writeXML (ByteStream &str_out) const
 Write out a DjVuXML object tag and map tag.
void writeXML (ByteStream &str_out, const GURL &doc_url, const int flags=0) const
 Write out a DjVuXML object tag and map tag.
Files #"DjVuPort.h"# and #"DjVuPort.cpp"# implement a communication mechanism between different parties involved in decoding DjVu files. It should be pretty clear that the creator of {DjVuDocument} and {DjVuFile} would like to receive some information about the progress of decoding, errors occurred, etc. It may also want to provide source data for decoders (like it's done in the plugin where the real data is downloaded from the net and is fed into DjVu decoders).

Normally this functionality is implemented by means of callbacks which are run when a given condition comes true. Unfortunately it's not quite easy to implement this strategy in our case. The reason is that there may be more than one "client" working with the same document, and the document should send the information to each of the clients. This could be done by means of callback {lists}, of course, but we want to achieve more bulletproof results: we want to be sure that the client that we're about to contact is still alive, and is not being destroyed by another thread. Besides, we are going to call these "callbacks" from many places, from many different classes. Maintaining multi-thread safe callback lists is very difficult.

Finally, we want to provide some default implementation of these "callbacks" in the library, which should attempt to process the requests themselves if they can, and contact the client only if they're unable to do it (like in the case of {DjVuPort::request_data}() with local URL where {DjVuDocument} can get the data from the hard drive itself not disturbing the document's creator.

Two classes implement a general communication mechanism: {DjVuPort} and {DjVuPortcaster}. Any sender and recipient of requests should be a subclass of {DjVuPort}. {DjVuPortcaster} maintains a map of routes between {DjVuPort}s, which should be configured by somebody else. Whenever a port wants to send a request, it calls the corresponding function of {DjVuPortcaster}, and the portcaster relays the request to all the destinations that it sees in the internal map.

The {DjVuPortcaster} is responsible for keeping the map up to date by getting rid of destinations that have been destroyed. Map updates are performed from a single place and are serialized by a global monitor.

DjVu decoder communication mechanism.

Andrei Erofeev <eaf@geocities.com>\ L\'eon Bottou <leonb@research.att.com>
DjVuPort.h,v 1.8 2003/11/07 22:08:21 leonb Exp

virtual bool inherits (const GUTF8String &class_name) const
Checking for legal DjVu files.

int is_legal_bilevel () const
int is_legal_compound () const
int is_legal_photo () const
New style decoding.

bool wait_for_complete_decode (void)

Static Public Member Functions

static DjVuPortcasterget_portcaster (void)
static void operator delete (void *addr)
static void * operator new (size_t sz)

Protected Attributes

volatile int count
 The reference counter.

Private Member Functions

GP< IW44Imageget_bg44 (const GP< DjVuFile > &file) const
GP< GPixmapget_bgpm (const GP< DjVuFile > &file) const
GP< DjVuPalette > get_fgbc (const GP< DjVuFile > &file) const
GP< JB2Imageget_fgjb (const GP< DjVuFile > &file) const
GP< GPixmapget_fgpm (const GP< DjVuFile > &file) const
GP< DjVuInfoget_info (const GP< DjVuFile > &file) const
void init_rotate (const DjVuInfo &info)
int stencil (GPixmap *pm, const GRect &rect, int subs, double gcorr) const

Private Attributes

GP< DjVuFilefile
bool relayout_sent
int rotate_count

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index