Logo Search packages:      
Sourcecode: djvulibre version File versions

GP< DjVuImage > DjVuDocument::get_page ( int  page_num,
bool  sync = true,
DjVuPort port = 0 
) const

Returns {GP} pointer to {DjVuImage} corresponding to page page_num#. If caching is enabled, and there is a {fully decoded} {DjVuFile} in the cache, the image will be reused and will be returned fully decoded. Otherwise, if multi-threaded behavior is allowed, and sync# is set to FALSE#, the decoding will be started in a separate thread, which enables to do progressive redisplay. Thus, in this case the image returned may be partially decoded.

Negative page_num# has a special meaning for the {old indexed} multipage documents: the DjVuDocument# will start decoding of the URL with which it has been initialized. For other formats page #-1# is the same as page #0#.

DjVuDocument# can also connect the created page to the specified port# {before starting decoding}. This option will allow the future owner of {DjVuImage} to receive all messages and requests generated during its decoding.

If this function is called before the document's structure becomes known (the initialization process completes), the {DjVuFile}, which the returned image will be attached to, will be assigned a temporary artificial URL, which will be corrected as soon as enough information becomes available. The trick prevents the main thread from blocking and in some cases helps to start decoding earlier. The URL is corrected and decoding will start as soon as DjVuDocument# passes some given stages of initialization and {page_to_url}(), {id_to_url}() functions start working properly. Please look through their description for details.

{ Note:} To wait for the initialization to complete use {wait_for_complete_init}(). For single threaded applications the initialization completes before the {init}() function returns.

page_num Number of the page to be decoded
sync When set to TRUE# the function will not return until the page is completely decoded. Otherwise, in a multi-threaded program, this function will start decoding in a new thread and will return a partially decoded image. Refer to {DjVuImage::wait_for_complete_decode}() and {DjVuFile::is_decode_ok}().
port A pointer to {DjVuPort}, that the created image will be connected to.

Definition at line 1027 of file DjVuDocument.cpp.

References DjVuPortcaster::add_route(), DjVuImage::create(), get_djvu_file(), and DjVuPort::get_portcaster().

Referenced by DjVuDocEditor::generate_thumbnails(), and writeDjVuXML().

   DEBUG_MSG("DjVuDocument::get_page(): request for page " << page_num << "\n");

   GP<DjVuImage> dimg;
   const GP<DjVuFile> file(get_djvu_file(page_num));
   if (file)
     if (port)
       DjVuPort::get_portcaster()->add_route(dimg, port);
     if (dimg && sync)
   return dimg;

Generated by  Doxygen 1.6.0   Back to index