#include <djv_jb2encoder.h>
|
virtual void | startParallel (size_t inPagesInParallel)=0 |
|
virtual bool | addPage (const u8 *inMaskPtr, ssize_t inMaskRowStride, MaskType inMaskType, size_t inWidth, size_t inHeight, const u8 *inImagePtr=NULL, ssize_t inImageRowStride=0, Photometric inImagePm=pmRGB8, const Params *inParams=NULL, size_t inPageIndex=0, OptimizationCallback inCallback=NULL, void *inContext=NULL, size_t *outPageIndex=NULL)=0 |
|
virtual size_t | getPageCount () const =0 |
|
virtual AutoPtr< const JB2Page > | getPage (size_t inIndex) const =0 |
|
virtual AutoPtr< JB2Page > | getPage (size_t inIndex)=0 |
|
virtual void | finalize (JB2Page::Array &outPages, OptimizationCallback inCallback=NULL, void *inContext=NULL)=0 |
|
| Referable () |
|
void | addRef () const |
|
void | releaseRef () const |
|
size_t | getReferenceCount () const |
|
This class provides a way to encode images with JB2 encoding.
This interface is provided for advanced purpose and you had better use DjVuEncoder for the normal purpose.
This class generates the data of the following chunks:
Sjbz
Shape data for a page.
See encodeSjbzChunk, encodeSjbz
Djbz
Shared dictionary. It does not exist if pages are using their own shape dictionaries in Sjbz
.
See encodeDjbzChunk, encodeDjbz
FGbz
Palette for shape data. It does not exist if the page is bi-tonal and no palette information needed.
See encodeFGbzChunk, encodeFGbz
typedef bool(* Celartem::DjVu::JB2Encoder::OptimizationCallback)(void *inContext, Shape *inCurrentShape, size_t inCurrentIndex, size_t inEndIndex) |
Callback definition used on addPage and finalize method.
- Parameters
-
inContext | The context specified on the method call. |
inCurrentShape | The shape, which will be optimized on this iteration. It is NULL if inCurrentIndex is equal to inEndIndex. |
inCurrentIndex | Current progress. It is no more than inEndIndex. |
inEndIndex | Progress maximum. When the method tries to notify the process is complete (100%), inCurrentIndex is set to the value equal to inEndIndex and inCurrentShape is set to NULL . |
- Returns
- If the callback function returns
true
, the shape will be processed (will be the target of optimization); otherwise if the function returns false
, the shape is not processed.
virtual bool Celartem::DjVu::JB2Encoder::addPage |
( |
const u8 * |
inMaskPtr, |
|
|
ssize_t |
inMaskRowStride, |
|
|
MaskType |
inMaskType, |
|
|
size_t |
inWidth, |
|
|
size_t |
inHeight, |
|
|
const u8 * |
inImagePtr = NULL , |
|
|
ssize_t |
inImageRowStride = 0 , |
|
|
Photometric |
inImagePm = pmRGB8 , |
|
|
const Params * |
inParams = NULL , |
|
|
size_t |
inPageIndex = 0 , |
|
|
OptimizationCallback |
inCallback = NULL , |
|
|
void * |
inContext = NULL , |
|
|
size_t * |
outPageIndex = NULL |
|
) |
| |
|
pure virtual |
Add a page to JB2Encoder work area.
This method only stores the specified image into the internal work area and returns immediately.
This method should not be called after calling one of encodeDjbz, encodeSjbz and encodeFGbz.
- Parameters
-
inMaskPtr | The pointer to the "first line" of the image mask.
The following formula correctly calculate the pointer to each line:
mask[n] = inMaskPtr + inMaskRowStride * n;
The image should be accessible until the encoding finishes.
In this mask, 0 means the foreground and 1 (0xff for unpacked case) does the background. |
inMaskRowStride | The row-stride in bytes of the mask specified by inMask. It can be negative if the image is bottom-up. |
inMaskType | The type of the mask. It should be one of MaskType enumeration. |
inWidth | The width of the image specified by inImagePtr and inMaskPtr. |
inHeight | The height of the image specified by inImagePtr and inMaskPtr. |
inImagePtr | The pointer to the "first line" of the image.
The following formula correctly calculate the pointer to each line:
line[n] = inImagePtr + inImageRowStride * n;
The image should be accessible until the encoding finishes.
It can be NULL if the image is bi-tonal (black and white 1bit) or the color of the foreground is encoded by other method (i.e. FG44). |
inImageRowStride | The row-stride in bytes of the image specified by inImagePtr. It can be negative if the image is bottom-up.
It can be 0 if the image is bi-tonal (black and white 1bit). |
inImagePm | The photometric of the image specified by inImagePtr. It is ignored if inImagePtr is NULL. |
inParams | Parameters fof JB2 encoding. |
inPageIndex | For parallel page conversion, this specifies the index of the page (0-based index of the page) to encode on this call; otherwise this parameter is ignored. |
inCallback | Callback function called during optimizing JB2 shapes. |
inContext | Context for the callback. |
outPageIndex | Optional; the resulting page index in the encoder. |
- Returns
true
if the JB2 encoder modifies the input mask for optimization purpose. The mask encoded to Sjbz
is different from the input mask and user code should update the mask accroding to the shapes for the page.
false
if no such optimization.
static AutoPtr<JB2Encoder> Celartem::DjVu::JB2Encoder::create |
( |
const Params * |
inParams = NULL , |
|
|
bool |
inUseDictionary = true |
|
) |
| |
|
static |
Create a new instance of JB2Encoder.
- Parameters
-
inParams | Parameters fof JB2 encoding. This can be NULL and the default parameters are used.
These parameters can be overwritten lately by the parameters explicitly passed to each addPage call. |
inUseDictionary | Whether to use dictionary or not for the JB2 page encoding. |
- Returns
- Pointer to the newly created JB2Encoder instance.
Finalize JB2 encoding.
After calling this method, the JB2Encoder instance is clears all the internal data and it can be reused to encode other pages.
- Parameters
-
outPages | Returns array of pages encoded. |
inCallback | Callback function called during optimizing JB2 shapes. |
inContext | Context for the callback. |
virtual AutoPtr<const JB2Page> Celartem::DjVu::JB2Encoder::getPage |
( |
size_t |
inIndex | ) |
const |
|
pure virtual |
Get access to the added page on the specified index.
This method is provided for advanced operations.
- Parameters
-
- Returns
- Pointer to the page.
virtual AutoPtr<JB2Page> Celartem::DjVu::JB2Encoder::getPage |
( |
size_t |
inIndex | ) |
|
|
pure virtual |
Get access to the added page on the specified index.
This method is provided for advanced operations.
- Parameters
-
- Returns
- Pointer to the page.
virtual size_t Celartem::DjVu::JB2Encoder::getPageCount |
( |
| ) |
const |
|
pure virtual |
Get the number of pages added to this JB2Encoder instance.
- Returns
- The number of pages in the JB2Encoder instance.
- See Also
- encodeSjbz, encodeFGbz
virtual void Celartem::DjVu::JB2Encoder::startParallel |
( |
size_t |
inPagesInParallel | ) |
|
|
pure virtual |
Starts parallel page conversion.
Pages can be converted concurrently with threads if starts with this function.
After call of this function, addPage function can be called concurrently in threads. finalize function should be called after all the threads (addPage call) finished.
- Parameters
-
inPagesInParallel | How many pages are encoded in parallel using threads. |
The documentation for this class was generated from the following file: