kviewshell
DjVuImage Class Reference
Main DjVu Image data structure. More...
#include <DjVuImage.h>
Public Types | |
enum | { NOINFO, NOTEXT = 1, NOMAP = 4, NOMETA = 8 } |
Public Member Functions | |
GP< GPixmap > | get_bg_pixmap (const GRect &rect, int subs=1, double gamma=0) const |
GP< GBitmap > | get_bitmap (const GRect &rect, int subs=1, int align=1) const |
GP< GPixmap > | get_fg_pixmap (const GRect &rect, int subs=1, double gamma=0) const |
GP< GPixmap > | get_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) |
Components. | |
GP< ByteStream > | get_anno () const |
GP< IW44Image > | get_bg44 () const |
GP< GPixmap > | get_bgpm () const |
GP< DjVuPalette > | get_fgbc () const |
GP< JB2Image > | get_fgjb () const |
GP< GPixmap > | get_fgpm () const |
GP< DjVuInfo > | get_info () const |
GP< ByteStream > | get_meta () const |
GP< ByteStream > | get_text () const |
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 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< GPixmap > | get_bg_pixmap (const GRect &rect, const GRect &all, double gamma=0) const |
GP< GBitmap > | get_bitmap (const GRect &rect, const GRect &all, int align=1) const |
GP< DjVuAnno > | get_decoded_anno () |
GP< GPixmap > | get_fg_pixmap (const GRect &rect, const GRect &all, double gamma=0) const |
GP< GPixmap > | get_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 |
Utilities | |
GP< DjVuFile > | get_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 |
GUTF8String | get_XML (const GURL &doc_url, const int flags=0) const |
void | writeXML (ByteStream &str_out) const |
void | writeXML (ByteStream &str_out, const GURL &doc_url, const int flags=0) 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) |
Protected Member Functions | |
DjVuImage (void) | |
Construction. | |
static GP< DjVuImage > | create (const GP< DjVuFile > &file) |
static GP< DjVuImage > | create (void) |
void | connect (const GP< DjVuFile > &file) |
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 138 of file DjVuImage.h.
Member Enumeration Documentation
anonymous enum |
Constructor & Destructor Documentation
DjVuImage::DjVuImage | ( | void | ) | [protected] |
Definition at line 93 of file DjVuImage.cpp.
Member Function Documentation
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.
Definition at line 99 of file DjVuImage.cpp.
This combines the above two steps for simplier code operations.
Definition at line 167 of file DjVuImage.h.
Creates 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 {DjVuFile}s 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.
Definition at line 156 of file DjVuImage.h.
void DjVuImage::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.
Definition at line 502 of file DjVuImage.cpp.
GP< ByteStream > DjVuImage::get_anno | ( | void | ) | 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.
Definition at line 223 of file DjVuImage.cpp.
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.
Definition at line 274 of file DjVuImage.cpp.
Definition at line 665 of file DjVuImage.cpp.
GP< GPixmap > DjVuImage::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.
Definition at line 1217 of file DjVuImage.cpp.
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.
Definition at line 283 of file DjVuImage.cpp.
Definition at line 648 of file DjVuImage.cpp.
Renders the mask of the foreground layer of the DjVu image.
This functions is a wrapper for {JB2Image::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.
Definition at line 1211 of file DjVuImage.cpp.
returns decoded annotations in DjVuAnno object in which all hyperlinks and hilighted areas are rotated as per rotation setting
map hyperlinks correctly for rotation
Definition at line 1246 of file DjVuImage.cpp.
Returns pointer to {DjVuFile} which contains this image in compressed form.
Definition at line 432 of file DjVuImage.h.
int DjVuImage::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.
Definition at line 354 of file DjVuImage.cpp.
Definition at line 1034 of file DjVuImage.cpp.
GP< GPixmap > DjVuImage::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.
Definition at line 1223 of file DjVuImage.cpp.
GP< DjVuPalette > DjVuImage::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.
Definition at line 310 of file DjVuImage.cpp.
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.
Definition at line 292 of file DjVuImage.cpp.
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.
Definition at line 301 of file DjVuImage.cpp.
double DjVuImage::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.
Definition at line 385 of file DjVuImage.cpp.
int DjVuImage::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. This gives rotated height if there is any rotation of image. If you need real width, use get_real_height()#.
Definition at line 326 of file DjVuImage.cpp.
Returns a pointer to a DjVu information component.
This function returns a null pointer until the decoder actually processes an #"INFO"# chunk.
Definition at line 211 of file DjVuImage.cpp.
GUTF8String DjVuImage::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. {verbatim} 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) {verbatim}
Definition at line 417 of file DjVuImage.cpp.
GP< ByteStream > DjVuImage::get_meta | ( | void | ) | const |
Returns a pointer to a ByteStream containing all the metadata.
Returns NULL if no chunks have been collected yet.
Definition at line 257 of file DjVuImage.cpp.
GUTF8String DjVuImage::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.
Definition at line 392 of file DjVuImage.cpp.
Definition at line 1053 of file DjVuImage.cpp.
GP< GPixmap > DjVuImage::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.
Definition at line 1205 of file DjVuImage.cpp.
int DjVuImage::get_real_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.
Definition at line 340 of file DjVuImage.cpp.
int DjVuImage::get_real_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.
Definition at line 333 of file DjVuImage.cpp.
int DjVuImage::get_rotate | ( | ) | const |
int DjVuImage::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.
Definition at line 361 of file DjVuImage.cpp.
GUTF8String DjVuImage::get_short_description | ( | ) | const |
Returns a short string describing the DjVu image.
Example: #"2500x3223 in 23.1 Kb"#.
Definition at line 401 of file DjVuImage.cpp.
GP< ByteStream > DjVuImage::get_text | ( | void | ) | const |
Returns a pointer to a ByteStream containing all the hidden text.
Returns NULL if no chunks have been collected yet.
Definition at line 240 of file DjVuImage.cpp.
int DjVuImage::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}.
Definition at line 347 of file DjVuImage.cpp.
int DjVuImage::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. This gives rotated width if there is any rotation of image. If you need real width, use get_real_width()#.
Definition at line 319 of file DjVuImage.cpp.
GUTF8String DjVuImage::get_XML | ( | void | ) | const |
GUTF8String DjVuImage::get_XML | ( | const GURL & | doc_url, | |
const int | flags = 0 | |||
) | const |
int DjVuImage::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.
Definition at line 543 of file DjVuImage.cpp.
int DjVuImage::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.
Definition at line 600 of file DjVuImage.cpp.
int DjVuImage::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.
Definition at line 571 of file DjVuImage.cpp.
void DjVuImage::map | ( | int & | x, | |
int & | y | |||
) | const |
maps the given x#, y# from rotated co-ordinates to unrotated document co-ordinates
Definition at line 1320 of file DjVuImage.cpp.
void DjVuImage::map | ( | GRect & | rect | ) | const |
maps the given rect# from rotated co-ordinates to unrotated document co-ordinates
Definition at line 1282 of file DjVuImage.cpp.
void DjVuImage::notify_chunk_done | ( | const DjVuPort * | source, | |
const GUTF8String & | name | |||
) | [virtual] |
This notification is sent when a new chunk has been decoded.
Reimplemented from DjVuPort.
Definition at line 424 of file DjVuImage.cpp.
void DjVuImage::set_rotate | ( | int | count = 0 |
) |
set the rotation count(angle) in counter clock wise for the image values (0,1,2,3) correspond to (0,90,180,270) degree rotation
Definition at line 1240 of file DjVuImage.cpp.
void DjVuImage::unmap | ( | int & | x, | |
int & | y | |||
) | const |
unmaps the given x#, y# from unrotated document co-ordinates to rotated co-ordinates
Definition at line 1339 of file DjVuImage.cpp.
void DjVuImage::unmap | ( | GRect & | rect | ) | const |
unmaps the given rect# from unrotated document co-ordinates to rotated co-ordinates
Definition at line 1301 of file DjVuImage.cpp.
bool DjVuImage::wait_for_complete_decode | ( | void | ) |
The decoder is now started when the image is created by function {DjVuDocument::get_page} in {DjVuDocument}.
This function waits until the decoding thread terminates and returns TRUE if the image has been successfully decoded.
Definition at line 1358 of file DjVuImage.cpp.
void DjVuImage::writeXML | ( | ByteStream & | str_out | ) | const |
void DjVuImage::writeXML | ( | ByteStream & | str_out, | |
const GURL & | doc_url, | |||
const int | flags = 0 | |||
) | const |
The documentation for this class was generated from the following files: