Celartem::DjVu::Page Class Reference

#include <djv_page.h>

Inheritance diagram for Celartem::DjVu::Page:

Inheritance graph
[legend]

List of all members.

Public Types

enum  RenderFlags { rfUseFastAlgorithm = 1, rfNoWaitForLoading = 2 }
enum  RenderMode {
  ForegroundNoMask = 1, MaskOnly = 2, ForegroundOnly = 3, BackgroundOnly = 4,
  FgAndBg = 5, BackgroundWithMask = 6, Normal = 7
}

Public Member Functions

virtual size_t getWidth () const =0
virtual size_t getHeight () const =0
virtual size_t getOriginalWidth () const =0
virtual size_t getOriginalHeight () const =0
virtual size_t getDpi () const =0
virtual void setDpi (size_t inDpi)=0
virtual size_t getFormatVersion () const =0
virtual void setFormatVersion (size_t version)=0
virtual Rotation getRotation () const =0
virtual void setRotation (Rotation inRotation)=0
virtual const ChunkgetTH44Chunk () const =0
virtual ChunkgetTH44Chunk ()=0
virtual void setTH44Chunk (Chunk *inTH44Chunk)=0
virtual void updateTH44Chunk (size_t inSize=96, bool inForceCreateTH44=false, IW44::IW44Encoder::Params *inIW44Params=NULL)=0
virtual bool renderThumbnail (u8 *outDest, ssize_t inDestRowStride, Photometric inDestPm, const Rect &inRect, size_t inRescaledWidth, size_t inRescaledHeight, bool inForceRenderThumbnail=true, u32 inFlags=0) const =0
virtual const PageInfogetPageInfo () const =0
virtual void updateChunks ()=0
virtual TextZonegetText ()=0
virtual const TextZonegetText () const =0
virtual AnnotationgetAnnotation ()=0
virtual const AnnotationgetAnnotation () const =0
virtual AnnotationgetSharedAnnotation ()=0
virtual const AnnotationgetSharedAnnotation () const =0
virtual void save (Storage *inStorage, const SecurityProvider *inSecProv=NULL, IFF::SerializationCallback inCallback=NULL, void *inContext=NULL, bool inForceReflectChanges=true) const =0
virtual const ChunkgetChunk () const =0
virtual ChunkgetChunk ()=0
virtual void render (u8 *outDest, ssize_t inDestRowStride, Photometric inDestPm, const Rect &inRect, size_t inRescaledWidth=0, size_t inRescaledHeight=0, RenderMode inRenderMode=Normal, u32 inFlags=0) const =0
virtual void render (u8 *outDest, ssize_t inDestRowStride, Photometric inDestPm, const Rect &inRect, size_t inRescaledWidth, size_t inRescaledHeight, RenderMode inRenderMode, Rotation inRotation, u32 inFlags=0) const =0
virtual void prerenderImageCaches (Photometric inPm) const =0
virtual Photometric getLastCachedImagePhotometric () const =0
virtual void clearImageCache () const =0
virtual const RenderergetFgRenderer (bool noWait=false) const =0
virtual const RenderergetBgRenderer (bool noWait=false) const =0
virtual const RenderergetMaskRenderer (bool noWait=false) const =0
virtual const IW44::IW44DecodergetBg44Decoder (bool noWait=false) const =0
virtual const IW44::IW44DecodergetFg44Decoder (bool noWait=false) const =0
virtual const JB2::JB2PagegetJB2Page (bool noWait=false) const =0
virtual void reloadChunks ()=0
virtual bool isLoaded () const =0
virtual void setOnChunkCallback (Chunk::OnChunkCallback inOnChunkCallback, void *inContext)=0

Static Public Member Functions

static AutoPtr< Pagecreate (Chunk *inChunk)
static AutoPtr< Pagecreate (Chunk *inChunk, Document *inDoc)


Detailed Description

This class provides an easy access to DJVU chunk based pages.
Please note that the methods on a Page instance is not serialized; they're not thread-safe. If you want to use the same instance between threads, you should lock the Chunk instance obtained with getChunk method (by calling lock or using Locker class) before manipulation on it. The following code illustrates this:
    Locker lock(*page->getChunk());
    page->render(...);

Definition at line 49 of file djv_page.h.


Member Enumeration Documentation

enum Celartem::DjVu::Page::RenderFlags

Flags to specify options for render, renderThumbnail functions.

Enumerator:
rfUseFastAlgorithm  Use faster algorithm.
rfNoWaitForLoading  Rendering does not wait for all the data loaded.

This flag is very useful when you don't want to wait for the chunk arrival.

Definition at line 219 of file djv_page.h.

enum Celartem::DjVu::Page::RenderMode

This enumeration defines rendering modes which is used by render methods.
The value is combination of the following independent components:

Enumerator:
ForegroundNoMask  Reserved.
MaskOnly  Render only mask layer.
ForegroundOnly  Render only foreground layer.
BackgroundOnly  Render only background layer.
FgAndBg  Reserved. (Impossible combination).
BackgroundWithMask  Reserved.
Normal  Render all the layers.

Definition at line 408 of file djv_page.h.


Member Function Documentation

static AutoPtr<Page> Celartem::DjVu::Page::create ( Chunk inChunk  )  [static]

Create a new Page instance from the specified chunk.

Parameters:
inChunk Pointer to a DJVU chunk.

static AutoPtr<Page> Celartem::DjVu::Page::create ( Chunk inChunk,
Document inDoc 
) [static]

Create a new Page instance from the specified chunk.

Parameters:
inChunk Pointer to a DJVU chunk.
inDoc Pointer to the Document instance which manages this instance. If no instance manages this Page instance, this can be NULL.
With this parameter, the page can share a JB2Dictionary instance to make dictionaries.

virtual size_t Celartem::DjVu::Page::getWidth (  )  const [pure virtual]

Get the width of the page.
This method returns the "rotated" width of the page. If you want to get the original width of the page, use getOriginalWidth method.

Returns:
The width of the page in pixels.

virtual size_t Celartem::DjVu::Page::getHeight (  )  const [pure virtual]

Get the height of the page.
This method returns the "rotated" height of the page. If you want to get the original height of the page, use getOriginalHeight method.

Returns:
The height of the page in pixels.

virtual size_t Celartem::DjVu::Page::getOriginalWidth (  )  const [pure virtual]

Get the original width of the page.

Returns:
The width of the page in pixels.

virtual size_t Celartem::DjVu::Page::getOriginalHeight (  )  const [pure virtual]

Get the original height of the page.

Returns:
The height of the page in pixels.

virtual size_t Celartem::DjVu::Page::getDpi (  )  const [pure virtual]

Get the resolution of the page in dot-per-inch.

Returns:
The page resolution in dot-per-inch.

virtual void Celartem::DjVu::Page::setDpi ( size_t  inDpi  )  [pure virtual]

Set the resolution of the page in dot-per-inch.
Please note that the modification by this method is not automatically reflected to the original chunk without explicit calls to updateChunks method.

Parameters:
inDpi The page resolution in dot-per-inch.

virtual size_t Celartem::DjVu::Page::getFormatVersion (  )  const [pure virtual]

Get the format version of the DJVU chunk.

Returns:
The DjVu format version.

virtual void Celartem::DjVu::Page::setFormatVersion ( size_t  version  )  [pure virtual]

Set the format version of the DJVU chunk. Please note that you should take much care when changing format version.

Parameters:
version The DjVu format version.

virtual Rotation Celartem::DjVu::Page::getRotation (  )  const [pure virtual]

Get the Rotation of the page.

Returns:
The page rotation status.

virtual void Celartem::DjVu::Page::setRotation ( Rotation  inRotation  )  [pure virtual]

Set the Rotation of the page.
Please note that the modification by this method is not automatically reflected to the original chunk without explicit calls to updateChunks method.

Parameters:
inRotation The page rotation status.

virtual const Chunk* Celartem::DjVu::Page::getTH44Chunk (  )  const [pure virtual]

Get the TH44 chunk of the page.
If no TH44 (thumbnail) is associated to the page, this method returns NULL.

Returns:
Pointer to the TH44 chunk.
You can decode TH44 chunk like the following code:
const Chunk* th44 = page->getTH44Chunk();
if(th44)
{
    AutoPtr<IW44Decoder> th44dec = IW44Decoder::create();
    th44dec->decode(th44);
    size_t w = th44dec->getWidth();
    size_t h = th44dec->getHeight();
    th44dec->render(....);
}

virtual Chunk* Celartem::DjVu::Page::getTH44Chunk (  )  [pure virtual]

Get the TH44 chunk of the page.
If no TH44 (thumbnail) is associated to the page, this method returns NULL.

Returns:
Pointer to the TH44 chunk.

virtual void Celartem::DjVu::Page::setTH44Chunk ( Chunk inTH44Chunk  )  [pure virtual]

Set a TH44 chunk to the page.

Parameters:
inTH44Chunk Pointer to a TH44 chunk to set to the page.

virtual void Celartem::DjVu::Page::updateTH44Chunk ( size_t  inSize = 96,
bool  inForceCreateTH44 = false,
IW44::IW44Encoder::Params *  inIW44Params = NULL 
) [pure virtual]

Recreate TH44 chunk from the page image.

Parameters:
inSize The new thumbnail size; the width/height of the newly generated thumbnail is fit into inSize x inSize bounding box.
inForceCreateTH44 Whether this method creates a new TH44 chunk or not; if no corresponding TH44 chunk is found.
This method does nothing if inForceCreateTH44 is false and no TH44 chunk is found.
inIW44Params Additional parameter to configure TH44 image quality and size. This can be NULL to use the default settings.

virtual bool Celartem::DjVu::Page::renderThumbnail ( u8 outDest,
ssize_t  inDestRowStride,
Photometric  inDestPm,
const Rect inRect,
size_t  inRescaledWidth,
size_t  inRescaledHeight,
bool  inForceRenderThumbnail = true,
u32  inFlags = 0 
) const [pure virtual]

Render the thumbnail image.
If you want to take more control of the thumbnail (to get the width/height, rendering quality, and so on), you had better use getTH44Chunk method rather than this.

Parameters:
outDest Pointer to a buffer which receives the rendered result.
inDestRowStride The row-stride of outDest.
inDestPm The photometric of the output image.
inRect Rectangle to draw in the rescaled image coordination.
inRescaledWidth The virtual width of the rescaled page image.
This method renders page image as if it had this width. If 0 is specified, the rendered image is same size to the original page size.
inRescaledHeight The virtual height of the rescaled page image.
This method renders page image as if it had this height. If 0 is specified, the rendered image is same size to the original page size.
inForceRenderThumbnail Whether this method creates thumbnail image from the page image when no TH44 chunk is found.
inFlags Any combination of RenderFlags enumerations.

virtual const PageInfo& Celartem::DjVu::Page::getPageInfo (  )  const [pure virtual]

Get the information of the page.
You cannot modify the parameters on the returned PageInfo instance with this methed. If you modify some of them, create PageInfo instance directly from PageInfo constructor.

Returns:
Reference to a PageInfo instance.

virtual void Celartem::DjVu::Page::updateChunks (  )  [pure virtual]

Reflect the changes of this instance to the original chunks.

virtual TextZone* Celartem::DjVu::Page::getText (  )  [pure virtual]

Get associated text.
Please note that the modifications to the returned instance is not automatically reflected to the original chunk without explicit calls to updateChunks method.

Returns:
Pointer to the text associated to this instance.

virtual const TextZone* Celartem::DjVu::Page::getText (  )  const [pure virtual]

Get associated text.

Returns:
Pointer to the text associated to this instance.

virtual Annotation* Celartem::DjVu::Page::getAnnotation (  )  [pure virtual]

Get associated annotation.

Returns:
Pointer to the annotation associated to this instance. Please note that the modifications to the returned instance is not automatically reflected to the original chunk without explicit calls to updateChunks method.

virtual const Annotation* Celartem::DjVu::Page::getAnnotation (  )  const [pure virtual]

Get associated annotation.

Returns:
Pointer to the annotation associated to this instance.

virtual Annotation* Celartem::DjVu::Page::getSharedAnnotation (  )  [pure virtual]

Get shared annotation.

Returns:
Pointer to the annotation shared by several pages. Please note that the shared annotation could not be updated in the usual way because of its nature. To ensure that an annotation is shared by all the pages in the document, you should do like the following sample code:
Annotation* sharedAnno = page->getSharedAnnotation();

// Insert code to edit the shared annotation here

AutoPtr<Chunk> antz = sharedAnno->encodeANTzChunk();
AutoPtr<Chunk> incl = ChunkRedirector::create(antz);

for(size_t i = 0; i < doc->getPages().getSize(); i++)
{
    Chunk* pageChunk = doc->getPages()[i]->getChunk();
    pageChunk->getChildren().push_back(incl);
}

virtual const Annotation* Celartem::DjVu::Page::getSharedAnnotation (  )  const [pure virtual]

Get shared annotation.

Returns:
Pointer to the annotation shared by several pages.

virtual void Celartem::DjVu::Page::save ( Storage inStorage,
const SecurityProvider inSecProv = NULL,
IFF::SerializationCallback  inCallback = NULL,
void *  inContext = NULL,
bool  inForceReflectChanges = true 
) const [pure virtual]

Write out the page to the storage in DjVu format.

Parameters:
inStorage Storage instance to write on.
inSecProv SecurityProvider instance if needed. It can be NULL.
inCallback Pointer to a function which is called during the serialization process.
inContext Pointer to a parameter which is passed to inCallback function.
inForceReflectChanges If ture, this method internally calls updateChunks before writing out the chunks to the storage; otherwise this method writes out the chunks as it is and the modifications you've done are not reflected to the output result.

virtual const Chunk* Celartem::DjVu::Page::getChunk (  )  const [pure virtual]

Get the actual Chunk instance.
Please note that modifications to the Annotation, TextZone and the other attributes are not reflected to the real chunk until you explicitly call updateChunks method.

Returns:
Pointer to the Chunk instance.

virtual Chunk* Celartem::DjVu::Page::getChunk (  )  [pure virtual]

Get the actual Chunk instance.
Please note that modifications to the Annotation, TextZone and the other attributes are not reflected to the real chunk until you explicitly call updateChunks method.

Returns:
Pointer to the Chunk instance.

virtual void Celartem::DjVu::Page::render ( u8 outDest,
ssize_t  inDestRowStride,
Photometric  inDestPm,
const Rect inRect,
size_t  inRescaledWidth = 0,
size_t  inRescaledHeight = 0,
RenderMode  inRenderMode = Normal,
u32  inFlags = 0 
) const [pure virtual]

Render the page image.

Parameters:
outDest Pointer to a buffer which receives the rendered result.
inDestRowStride The row-stride of outDest.
inDestPm The photometric of the output image.
inRect Rectangle to draw in the rescaled image coordination.
inRescaledWidth The virtual width of the rescaled page image.
This method renders page image as if it had this width. If 0 is specified, the rendered image is same size to the original page size.
inRescaledHeight The virtual height of the rescaled page image.
This method renders page image as if it had this height. If 0 is specified, the rendered image is same size to the original page size.
inRenderMode Rendering mode by one of RenderMode enumeration.
inFlags Any combination of RenderFlags enumerations.

virtual void Celartem::DjVu::Page::render ( u8 outDest,
ssize_t  inDestRowStride,
Photometric  inDestPm,
const Rect inRect,
size_t  inRescaledWidth,
size_t  inRescaledHeight,
RenderMode  inRenderMode,
Rotation  inRotation,
u32  inFlags = 0 
) const [pure virtual]

Render the page image.

Parameters:
outDest Pointer to a buffer which receives the rendered result.
inDestRowStride The row-stride of outDest.
inDestPm The photometric of the output image.
inRect Rectangle to draw in the rescaled image coordination.
inRescaledWidth The virtual width of the rescaled page image.
This method renders page image as if it had this width. If 0 is specified, the rendered image is same size to the original page size.
inRescaledHeight The virtual height of the rescaled page image.
This method renders page image as if it had this height. If 0 is specified, the rendered image is same size to the original page size.
inRenderMode Rendering mode by one of RenderMode enumeration.
inRotation The rotation of the page.
With this parameter, you can override the rotation status enforced by the page.
inFlags Any combination of RenderFlags enumerations.

virtual void Celartem::DjVu::Page::prerenderImageCaches ( Photometric  inPm  )  const [pure virtual]

Pre-render the internal foreground/background images.
You can use this method in the background thread.

Parameters:
inPm The photometric of the output image.

virtual Photometric Celartem::DjVu::Page::getLastCachedImagePhotometric (  )  const [pure virtual]

Get the photometric of the last cached image.

Returns:
The photometric of the last cached image.

virtual void Celartem::DjVu::Page::clearImageCache (  )  const [pure virtual]

Clear cached rendering results.
This method clears internal data which are cached for repeated use of render methods. This actually reduces the memory usage of the instance but it may affect the performance of render methods.

virtual const Renderer* Celartem::DjVu::Page::getFgRenderer ( bool  noWait = false  )  const [pure virtual]

Get the Renderer instance used by this page to render the foreground.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the Renderer instance if it exists; otherwise NULL.

virtual const Renderer* Celartem::DjVu::Page::getBgRenderer ( bool  noWait = false  )  const [pure virtual]

Get the Renderer instance used by this page to render the background.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the Renderer instance if it exists; otherwise NULL.

virtual const Renderer* Celartem::DjVu::Page::getMaskRenderer ( bool  noWait = false  )  const [pure virtual]

Get the Renderer instance used by this page to render the mask.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the Renderer instance if it exists; otherwise NULL.

virtual const IW44::IW44Decoder* Celartem::DjVu::Page::getBg44Decoder ( bool  noWait = false  )  const [pure virtual]

Get the IW44Decoder instance which decodes the background.
This method internally calls getBgRenderer method and then use dynamic_cast against the instance returned by Renderer::getInternalRenderer method.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the IW44::IW44Decoder instance of the background

virtual const IW44::IW44Decoder* Celartem::DjVu::Page::getFg44Decoder ( bool  noWait = false  )  const [pure virtual]

Get the IW44Decoder instance which decodes the foreground.
This method internally calls getBgRenderer method and then use dynamic_cast against the instance returned by Renderer::getInternalRenderer method.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the IW44::IW44Decoder instance of the foreground.

virtual const JB2::JB2Page* Celartem::DjVu::Page::getJB2Page ( bool  noWait = false  )  const [pure virtual]

Get the JB2Page instance which decodes the mask.
This method internally calls getBgRenderer method and then use dynamic_cast against the instance returned by Renderer::getInternalRenderer method.

Parameters:
noWait true to instruct not to acquire lock during getting the instance. The default is false.
Returns:
Pointer to the JB2::JB2Page instance.

virtual void Celartem::DjVu::Page::reloadChunks (  )  [pure virtual]

Discards the modifications on this Page instance and reload the real Chunk instance assocaited to it.

virtual bool Celartem::DjVu::Page::isLoaded (  )  const [pure virtual]

Gets loaded flag.
This method is for internal purpose only.

Returns:
true if the chunk data is loaded; otherwise false.

virtual void Celartem::DjVu::Page::setOnChunkCallback ( Chunk::OnChunkCallback  inOnChunkCallback,
void *  inContext 
) [pure virtual]

Sets a callback which is called on every chunk loaded event.

Parameters:
inOnChunkCallback Pointer to a callback function which will be called when each chunk is loaded.
inContext A user defined data which is passed to the callback function.


The documentation for this class was generated from the following file:
This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:28 2008.