Public Types | Public Member Functions | Static Public Member Functions

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, rfNoWhiteFill = 4 }
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 const PageInfogetOriginalPageInfo () 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, 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 preload () const =0
virtual void unload () const =0
virtual bool isRendererReady () 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 IW44DecodergetBg44Decoder (bool noWait=false) const =0
virtual const IW44DecodergetFg44Decoder (bool noWait=false) const =0
virtual const 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(...);

Member Enumeration Documentation

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.

rfNoWhiteFill 

Never fill background even if background is not supplied.

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

  • Foreground (1)
  • Mask (2)
  • Background (4)
  • Opacity (8)
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.


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 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 const 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 IW44Decoder instance of the background
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 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 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 const 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 IW44Decoder instance of the foreground.
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 size_t Celartem::DjVu::Page::getFormatVersion (  )  const [pure virtual]

Get the format version of the DJVU chunk.

Returns:
The DjVu format version.
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 const 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 JB2Page instance.
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 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 const PageInfo& Celartem::DjVu::Page::getOriginalPageInfo (  )  const [pure virtual]

Get the original information of the page.

Returns:
Reference to a PageInfo instance.
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 const PageInfo& Celartem::DjVu::Page::getPageInfo (  )  const [pure virtual]

Get the information of the page. Reference to a PageInfo instance.

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

Get the Rotation of the page.

Returns:
The page rotation status.
virtual Annotation* Celartem::DjVu::Page::getSharedAnnotation (  )  [pure virtual]
Deprecated:
This method is only for backward compatibility, new applications should use Document::getSharedAnnotation methods. 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.
virtual const Annotation* Celartem::DjVu::Page::getSharedAnnotation (  )  const [pure virtual]
Deprecated:
This method is only for backward compatibility, new applications should use Document::getSharedAnnotation methods. Get shared annotation.
Returns:
Pointer to the annotation shared by several pages.
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 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 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 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 bool Celartem::DjVu::Page::isRendererReady (  )  const [pure virtual]

Whether the renderer is ready to render the image or not.
This method actually determines whether the data is preloaded either partially or fully.

Returns:
true if ready; otherwise false.
virtual void Celartem::DjVu::Page::preload (  )  const [pure virtual]

Load all the data to render the image.
You can call this method ahead of render method to make it faster to render the image. This method is designed to called from non GUI thread.

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 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::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 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 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 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 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 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.
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 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::unload (  )  const [pure virtual]

Unload cached data for rendering.
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 void Celartem::DjVu::Page::updateChunks (  )  [pure virtual]

Reflect the changes of this instance to the original chunks.

virtual void Celartem::DjVu::Page::updateTH44Chunk ( size_t  inSize = 96,
bool  inForceCreateTH44 = false,
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.

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

This document is made with doxygen 1.7.1 at Thu Feb 17 2011 15:40:21.
Caminova Logo