![]() |
Leptonica
1.83.1
Image processing and image analysis suite
|
Go to the source code of this file.
Functions | |
static l_int32 | pixacompExtendArray (PIXAC *pixac) |
static l_int32 | pixcompFastConvertToPdfData (PIXC *pixc, const char *title, l_uint8 **pdata, size_t *pnbytes) |
PIXC * | pixcompCreateFromPix (PIX *pix, l_int32 comptype) |
PIXC * | pixcompCreateFromString (l_uint8 *data, size_t size, l_int32 copyflag) |
PIXC * | pixcompCreateFromFile (const char *filename, l_int32 comptype) |
void | pixcompDestroy (PIXC **ppixc) |
PIXC * | pixcompCopy (PIXC *pixcs) |
l_ok | pixcompGetDimensions (PIXC *pixc, l_int32 *pw, l_int32 *ph, l_int32 *pd) |
l_ok | pixcompGetParameters (PIXC *pixc, l_int32 *pxres, l_int32 *pyres, l_int32 *pcomptype, l_int32 *pcmapflag) |
l_ok | pixcompDetermineFormat (l_int32 comptype, l_int32 d, l_int32 cmapflag, l_int32 *pformat) |
PIX * | pixCreateFromPixcomp (PIXC *pixc) |
PIXAC * | pixacompCreate (l_int32 n) |
PIXAC * | pixacompCreateWithInit (l_int32 n, l_int32 offset, PIX *pix, l_int32 comptype) |
PIXAC * | pixacompCreateFromPixa (PIXA *pixa, l_int32 comptype, l_int32 accesstype) |
PIXAC * | pixacompCreateFromFiles (const char *dirname, const char *substr, l_int32 comptype) |
PIXAC * | pixacompCreateFromSA (SARRAY *sa, l_int32 comptype) |
void | pixacompDestroy (PIXAC **ppixac) |
l_ok | pixacompAddPix (PIXAC *pixac, PIX *pix, l_int32 comptype) |
l_ok | pixacompAddPixcomp (PIXAC *pixac, PIXC *pixc, l_int32 copyflag) |
l_ok | pixacompReplacePix (PIXAC *pixac, l_int32 index, PIX *pix, l_int32 comptype) |
l_ok | pixacompReplacePixcomp (PIXAC *pixac, l_int32 index, PIXC *pixc) |
l_ok | pixacompAddBox (PIXAC *pixac, BOX *box, l_int32 copyflag) |
l_int32 | pixacompGetCount (PIXAC *pixac) |
PIXC * | pixacompGetPixcomp (PIXAC *pixac, l_int32 index, l_int32 copyflag) |
PIX * | pixacompGetPix (PIXAC *pixac, l_int32 index) |
l_ok | pixacompGetPixDimensions (PIXAC *pixac, l_int32 index, l_int32 *pw, l_int32 *ph, l_int32 *pd) |
BOXA * | pixacompGetBoxa (PIXAC *pixac, l_int32 accesstype) |
l_int32 | pixacompGetBoxaCount (PIXAC *pixac) |
BOX * | pixacompGetBox (PIXAC *pixac, l_int32 index, l_int32 accesstype) |
l_ok | pixacompGetBoxGeometry (PIXAC *pixac, l_int32 index, l_int32 *px, l_int32 *py, l_int32 *pw, l_int32 *ph) |
l_int32 | pixacompGetOffset (PIXAC *pixac) |
l_ok | pixacompSetOffset (PIXAC *pixac, l_int32 offset) |
PIXA * | pixaCreateFromPixacomp (PIXAC *pixac, l_int32 accesstype) |
l_ok | pixacompJoin (PIXAC *pixacd, PIXAC *pixacs, l_int32 istart, l_int32 iend) |
PIXAC * | pixacompInterleave (PIXAC *pixac1, PIXAC *pixac2) |
PIXAC * | pixacompRead (const char *filename) |
PIXAC * | pixacompReadStream (FILE *fp) |
PIXAC * | pixacompReadMem (const l_uint8 *data, size_t size) |
l_ok | pixacompWrite (const char *filename, PIXAC *pixac) |
l_ok | pixacompWriteStream (FILE *fp, PIXAC *pixac) |
l_ok | pixacompWriteMem (l_uint8 **pdata, size_t *psize, PIXAC *pixac) |
l_ok | pixacompConvertToPdf (PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, const char *fileout) |
l_ok | pixacompConvertToPdfData (PIXAC *pixac, l_int32 res, l_float32 scalefactor, l_int32 type, l_int32 quality, const char *title, l_uint8 **pdata, size_t *pnbytes) |
l_ok | pixacompFastConvertToPdfData (PIXAC *pixac, const char *title, l_uint8 **pdata, size_t *pnbytes) |
l_ok | pixacompWriteStreamInfo (FILE *fp, PIXAC *pixac, const char *text) |
l_ok | pixcompWriteStreamInfo (FILE *fp, PIXC *pixc, const char *text) |
PIX * | pixacompDisplayTiledAndScaled (PIXAC *pixac, l_int32 outdepth, l_int32 tilewidth, l_int32 ncols, l_int32 background, l_int32 spacing, l_int32 border) |
l_ok | pixacompWriteFiles (PIXAC *pixac, const char *subdir) |
l_ok | pixcompWriteFile (const char *rootname, PIXC *pixc) |
Variables | |
static const l_uint32 | MaxPtrArraySize = 1000000 |
static const l_int32 | InitialPtrArraySize = 20 |
static const size_t | MaxDataSize = 1000000000 |
l_int32 | NumImageFileFormatExtensions |
const char * | ImageFileFormatExtensions [] |
Pixcomp creation and destruction PIXC *pixcompCreateFromPix() PIXC *pixcompCreateFromString() PIXC *pixcompCreateFromFile() void pixcompDestroy() PIXC *pixcompCopy() Pixcomp accessors l_int32 pixcompGetDimensions() l_int32 pixcompGetParameters() Pixcomp compression selection l_int32 pixcompDetermineFormat() Pixcomp conversion to Pix PIX *pixCreateFromPixcomp() Pixacomp creation and destruction PIXAC *pixacompCreate() PIXAC *pixacompCreateWithInit() PIXAC *pixacompCreateFromPixa() PIXAC *pixacompCreateFromFiles() PIXAC *pixacompCreateFromSA() void pixacompDestroy() Pixacomp addition/replacement l_int32 pixacompAddPix() l_int32 pixacompAddPixcomp() static l_int32 pixacompExtendArray() l_int32 pixacompReplacePix() l_int32 pixacompReplacePixcomp() l_int32 pixacompAddBox() Pixacomp accessors l_int32 pixacompGetCount() PIXC *pixacompGetPixcomp() PIX *pixacompGetPix() l_int32 pixacompGetPixDimensions() BOXA *pixacompGetBoxa() l_int32 pixacompGetBoxaCount() BOX *pixacompGetBox() l_int32 pixacompGetBoxGeometry() l_int32 pixacompGetOffset() l_int32 pixacompSetOffset() Pixacomp conversion to Pixa PIXA *pixaCreateFromPixacomp() Combining pixacomp l_int32 pixacompJoin() PIXAC *pixacompInterleave() Pixacomp serialized I/O PIXAC *pixacompRead() PIXAC *pixacompReadStream() PIXAC *pixacompReadMem() l_int32 pixacompWrite() l_int32 pixacompWriteStream() l_int32 pixacompWriteMem() Conversion to pdf l_int32 pixacompConvertToPdf() l_int32 pixacompConvertToPdfData() l_int32 pixacompFastConvertToPdfData() Output for debugging l_int32 pixacompWriteStreamInfo() l_int32 pixcompWriteStreamInfo() PIX *pixacompDisplayTiledAndScaled() l_int32 pixacompWriteFiles() l_int32 pixcompWriteFile() The Pixacomp is an array of Pixcomp, where each Pixcomp is a compressed string of the image. We don't use reference counting here. The basic application is to allow a large array of highly compressible images to reside in memory. We purposely don't reuse the Pixa for this, to avoid confusion and programming errors. Three compression formats are used: g4, png and jpeg. The compression type can be either specified or defaulted. If specified and it is not possible to compress (for example, you specify a jpeg on a 1 bpp image or one with a colormap), the compression type defaults to png. The jpeg compression quality can be specified using l_setJpegQuality(); otherwise the default is 75. The serialized version of the Pixacomp is similar to that for a Pixa, except that each Pixcomp can be compressed by one of tiffg4, png, or jpeg. Unlike serialization of the Pixa, serialization of the Pixacomp does not require any imaging libraries because it simply reads and writes the compressed data. There are two modes of use in accumulating images: (1) addition to the end of the array (2) random insertion (replacement) into the array In use, we assume that the array is fully populated up to the index value (n - 1), where n is the value of the pixcomp field n. Addition can only be made to the end of the fully populated array, at the index value n. Insertion can be made randomly, but again only within the array of pixcomps; i.e., within the set of indices {0 .... n-1}. The functions are pixacompReplacePix() and pixacompReplacePixcomp(), and they destroy the existing pixcomp. For addition to the end of the array, initialize the pixacomp with pixacompCreate(), which generates an empty array of pixcomps ptrs. For random insertion and replacement of pixcomp into a pixacomp, initialize a fully populated array using pixacompCreateWithInit(). The offset field allows you to use an offset-based index to access the 0-based ptr array in the pixacomp. This would typically be used to map the pixacomp array index to a page number, or v.v. By default, the offset is 0. For example, suppose you have 50 images, corresponding to page numbers 10 - 59. Then you could use pixac = pixacompCreateWithInit(50, 10, ...); This would allocate an array of 50 pixcomps, but if you asked for the pix at index 10, using pixacompGetPix(pixac, 10), it would apply the offset internally, returning the pix at index 0 in the array.
Definition in file pixcomp.c.
[in] | pixac | |
[in] | box | |
[in] | copyflag | L_INSERT, L_COPY |
Definition at line 1095 of file pixcomp.c.
References PixaComp::boxa, boxaAddBox(), L_COPY, and L_INSERT.
Referenced by pixacompInterleave().
[in] | pixac | |
[in] | pix | to be added |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) The array is filled up to the (n-1)-th element, and this converts the input pix to a pixc and adds it at the n-th position. (2) The pixc produced from the pix is owned by the pixac. The input pix is not affected.
[in] | pixac | |
[in] | pixc | to be added by insertion |
[in] | copyflag | L_INSERT, L_COPY |
Notes: (1) Anything added to a pixac is owned by the pixac. So do not L_INSERT a pixc that is owned by another pixac, or destroy a pixc that has been L_INSERTed.
Definition at line 934 of file pixcomp.c.
References L_COPY, L_INSERT, PixaComp::n, PixaComp::nalloc, pixacompExtendArray(), PixaComp::pixc, and pixcompCopy().
Referenced by pixacompInterleave(), and pixacompJoin().
l_ok pixacompConvertToPdf | ( | PIXAC * | pixac, |
l_int32 | res, | ||
l_float32 | scalefactor, | ||
l_int32 | type, | ||
l_int32 | quality, | ||
const char * | title, | ||
const char * | fileout | ||
) |
[in] | pixac | containing images all at the same resolution |
[in] | res | override the resolution of each input image, in ppi; 0 to respect the resolution embedded in the input |
[in] | scalefactor | scaling factor applied to each image; > 0.0 |
[in] | type | encoding type (L_JPEG_ENCODE, L_G4_ENCODE, L_FLATE_ENCODE, L_JP2K_ENCODE, or L_DEFAULT_ENCODE for default) |
[in] | quality | used for JPEG only; 0 for default (75) |
[in] | title | [optional] pdf title |
[in] | fileout | pdf file of all images |
Notes: (1) This follows closely the function pixaConvertToPdf() in pdfio.c. (2) The images are encoded with G4 if 1 bpp; JPEG if 8 bpp without colormap and many colors, or 32 bpp; FLATE for anything else. (3) The scalefactor must be > 0.0; otherwise it is set to 1.0. (4) Specifying one of the three encoding types for type forces all images to be compressed with that type. Use 0 to have the type determined for each image based on depth and whether or not it has a colormap. (5) If all images are jpeg compressed, don't require scaling and have the same resolution, it is much faster to skip transcoding with pixacompFastConvertToPdfData(), and then write the data out to file.
Definition at line 1923 of file pixcomp.c.
References l_binaryWrite(), and pixacompConvertToPdfData().
l_ok pixacompConvertToPdfData | ( | PIXAC * | pixac, |
l_int32 | res, | ||
l_float32 | scalefactor, | ||
l_int32 | type, | ||
l_int32 | quality, | ||
const char * | title, | ||
l_uint8 ** | pdata, | ||
size_t * | pnbytes | ||
) |
[in] | pixac | containing images all at the same resolution |
[in] | res | input resolution of all images |
[in] | scalefactor | scaling factor applied to each image; > 0.0 |
[in] | type | encoding type (L_JPEG_ENCODE, L_G4_ENCODE, L_FLATE_ENCODE, L_JP2K_ENCODE, or L_DEFAULT_ENCODE for default) |
[in] | quality | used for JPEG only; 0 for default (75) |
[in] | title | [optional] pdf title |
[out] | pdata | output pdf data (of all images |
[out] | pnbytes | size of output pdf data |
Notes: (1) See pixacompConvertToPdf().
Definition at line 1974 of file pixcomp.c.
References L_DEFAULT_ENCODE, L_FLATE_ENCODE, L_G4_ENCODE, L_JP2K_ENCODE, L_JPEG_ENCODE, pixacompGetCount(), pixacompGetOffset(), pixacompGetPix(), and ptraCreate().
Referenced by pixacompConvertToPdf().
PIXAC* pixacompCreate | ( | l_int32 | n | ) |
[in] | n | initial number of ptrs |
Definition at line 592 of file pixcomp.c.
Referenced by partifyPixac(), and pixacompInterleave().
PIXAC* pixacompCreateFromFiles | ( | const char * | dirname, |
const char * | substr, | ||
l_int32 | comptype | ||
) |
[in] | dirname | |
[in] | substr | [optional] substring filter on filenames; can be null |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) dirname is the full path for the directory. (2) substr is the part of the file name (excluding the directory) that is to be matched. All matching filenames are read into the Pixa. If substr is NULL, all filenames are read into the Pixa. (3) Use comptype == IFF_DEFAULT to have the compression type automatically determined for each file. (4) If the comptype is invalid for a file, the default will be substituted.
Definition at line 774 of file pixcomp.c.
Referenced by partifyFiles().
[in] | pixa | |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
[in] | accesstype | L_COPY, L_CLONE, L_COPY_CLONE |
Notes: (1) If format == IFF_DEFAULT, the conversion format for each image is chosen automatically. Otherwise, we use the specified format unless it can't be done (e.g., jpeg for a 1, 2 or 4 bpp pix, or a pix with a colormap), in which case we use the default (assumed best) compression. (2) accesstype is used to extract a boxa from pixa. (3) To compress jpeg with a quality other than the default (75), use l_jpegSetQuality()
[in] | sa | full pathnames for all files |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) Use comptype == IFF_DEFAULT to have the compression type automatically determined for each file. (2) If the comptype is invalid for a file, the default will be substituted.
[in] | n | initial number of ptrs |
[in] | offset | difference: accessor index - pixacomp array index |
[in] | pix | [optional] initialize each ptr in pixacomp to this pix; can be NULL |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) Initializes a pixacomp to be fully populated with pix, compressed using comptype. If pix == NULL, comptype is ignored. (2) Typically, the array is initialized with a tiny pix. This is most easily done by setting pix == NULL, causing initialization of each array element with a tiny placeholder pix (w = h = d = 1), using comptype = IFF_TIFF_G4 . (3) Example usage: // Generate pixacomp for pages 30 - 49. This has an array // size of 20 and the page number offset is 30. PixaComp *pixac = pixacompCreateWithInit(20, 30, NULL, IFF_TIFF_G4); // Now insert png-compressed images into the initialized array for (pageno = 30; pageno < 50; pageno++) { Pix *pixt = ... // derived from image[pageno] if (pixt) pixacompReplacePix(pixac, pageno, pixt, IFF_PNG); pixDestroy(&pixt); } The result is a pixac with 20 compressed strings, and with selected pixt replacing the placeholders. To extract the image for page 38, which is decompressed from element 8 in the array, use: pixt = pixacompGetPix(pixac, 38);
void pixacompDestroy | ( | PIXAC ** | ppixac | ) |
[in,out] | ppixac | use ptr address so it will be nulled |
Notes: (1) Always nulls the input ptr.
Definition at line 851 of file pixcomp.c.
References PixaComp::boxa, boxaDestroy(), PixaComp::n, PixaComp::pixc, and pixcompDestroy().
Referenced by pixaReadBoth().
PIX* pixacompDisplayTiledAndScaled | ( | PIXAC * | pixac, |
l_int32 | outdepth, | ||
l_int32 | tilewidth, | ||
l_int32 | ncols, | ||
l_int32 | background, | ||
l_int32 | spacing, | ||
l_int32 | border | ||
) |
pixacompDisplayTiledAndScaled()
[in] | pixac | |
[in] | outdepth | output depth: 1, 8 or 32 bpp |
[in] | tilewidth | each pix is scaled to this width |
[in] | ncols | number of tiles in each row |
[in] | background | 0 for white, 1 for black; this is the color of the spacing between the images |
[in] | spacing | between images, and on outside |
[in] | border | width of additional black border on each image; use 0 for no border |
Notes: (1) This is the same function as pixaDisplayTiledAndScaled(), except it works on a Pixacomp instead of a Pix. It is particularly useful for showing the images in a Pixacomp at reduced resolution. (2) See pixaDisplayTiledAndScaled() for details.
Definition at line 2305 of file pixcomp.c.
References L_COPY, pixaCreateFromPixacomp(), pixaDestroy(), and pixaDisplayTiledAndScaled().
|
static |
[in] | pixac |
Notes: (1) We extend the boxa array simultaneously. This is necessary in case we are NOT adding boxes simultaneously with adding pixc. We always want the sizes of the pixac and boxa ptr arrays to be equal. (2) The max number of pixcomp ptrs is 1M.
Definition at line 979 of file pixcomp.c.
References PixaComp::nalloc.
Referenced by pixacompAddPixcomp().
l_ok pixacompFastConvertToPdfData | ( | PIXAC * | pixac, |
const char * | title, | ||
l_uint8 ** | pdata, | ||
size_t * | pnbytes | ||
) |
pixacompFastConvertToPdfData()
[in] | pixac | containing images all at the same resolution |
[in] | title | [optional] pdf title |
[out] | pdata | output pdf data (of all images |
[out] | pnbytes | size of output pdf data |
Notes: (1) This generates the pdf without transcoding if all the images in pixac are compressed with jpeg. Images not jpeg compressed are skipped. (2) It assumes all images have the same resolution, and that the resolution embedded in each jpeg file is correct.
Definition at line 2088 of file pixcomp.c.
References L_NOCOPY, pixacompGetCount(), pixacompGetPixcomp(), pixcompGetParameters(), and ptraCreate().
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[in] | accesstype | L_COPY or L_CLONE |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array. (2) There is always a boxa with a pixac, and it is initialized so that each box ptr is NULL. (3) In general, we expect that there is either a box associated with each pixc, or no boxes at all in the boxa. (4) Having no boxes is thus not an automatic error. Whether it is an actual error is determined by the calling program. If the caller expects to get a box, it is an error; see, e.g., pixacGetBoxGeometry().
Definition at line 1300 of file pixcomp.c.
References Boxa::box, PixaComp::boxa, boxClone(), boxCopy(), L_CLONE, L_COPY, Boxa::n, and PixaComp::offset.
Referenced by pixacompGetBoxGeometry(), and pixacompInterleave().
[in] | pixac | |
[in] | accesstype | L_COPY, L_CLONE, L_COPY_CLONE |
Definition at line 1245 of file pixcomp.c.
References PixaComp::boxa, boxaCopy(), L_CLONE, L_COPY, and L_COPY_CLONE.
Referenced by pixacompJoin(), and pixaCreateFromPixacomp().
l_int32 pixacompGetBoxaCount | ( | PIXAC * | pixac | ) |
[in] | pixac |
Definition at line 1267 of file pixcomp.c.
References PixaComp::boxa, and boxaGetCount().
Referenced by pixacompInterleave(), pixacompJoin(), and pixacompWriteStreamInfo().
l_ok pixacompGetBoxGeometry | ( | PIXAC * | pixac, |
l_int32 | index, | ||
l_int32 * | px, | ||
l_int32 * | py, | ||
l_int32 * | pw, | ||
l_int32 * | ph | ||
) |
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[out] | px,py,pw,ph | [optional] each can be null |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array.
Definition at line 1345 of file pixcomp.c.
References boxDestroy(), boxGetGeometry(), L_CLONE, PixaComp::n, PixaComp::offset, and pixacompGetBox().
l_int32 pixacompGetCount | ( | PIXAC * | pixac | ) |
[in] | pixac |
Definition at line 1121 of file pixcomp.c.
References PixaComp::n.
Referenced by dewarpaCreateFromPixacomp(), partifyPixac(), pixacompConvertToPdfData(), pixacompFastConvertToPdfData(), pixacompInterleave(), pixacompJoin(), pixacompReplacePix(), pixacompReplacePixcomp(), pixacompWriteFiles(), pixacompWriteStream(), pixacompWriteStreamInfo(), and pixaCreateFromPixacomp().
l_int32 pixacompGetOffset | ( | PIXAC * | pixac | ) |
[in] | pixac |
Notes: (1) The offset is the difference between the caller's view of the index into the array and the actual array index. By default it is 0.
Definition at line 1383 of file pixcomp.c.
References PixaComp::offset.
Referenced by dewarpaCreateFromPixacomp(), pixacompConvertToPdfData(), and pixaCreateFromPixacomp().
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array.
Definition at line 1182 of file pixcomp.c.
References L_NOCOPY, PixaComp::n, PixaComp::offset, pixacompGetPixcomp(), and pixCreateFromPixcomp().
Referenced by dewarpaCreateFromPixacomp(), partifyPixac(), pixacompConvertToPdfData(), and pixaCreateFromPixacomp().
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[in] | copyflag | L_NOCOPY, L_COPY |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array. (2) If copyflag == L_NOCOPY, the pixc is owned by pixac; do not destroy.
Definition at line 1147 of file pixcomp.c.
References L_COPY, L_NOCOPY, PixaComp::n, PixaComp::offset, PixaComp::pixc, and pixcompCopy().
Referenced by pixacompFastConvertToPdfData(), pixacompGetPix(), pixacompInterleave(), pixacompJoin(), pixacompReplacePixcomp(), pixacompWriteFiles(), pixacompWriteStream(), and pixacompWriteStreamInfo().
l_ok pixacompGetPixDimensions | ( | PIXAC * | pixac, |
l_int32 | index, | ||
l_int32 * | pw, | ||
l_int32 * | ph, | ||
l_int32 * | pd | ||
) |
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[out] | pw,ph,pd | [optional] each can be null |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array.
Definition at line 1215 of file pixcomp.c.
References PixaComp::n, PixaComp::offset, PixaComp::pixc, and pixcompGetDimensions().
[in] | pixac1 | first src pixac |
[in] | pixac2 | second src pixac |
Notes: (1) If the two pixac have different sizes, a warning is issued, and the number of pairs returned is the minimum size.
Definition at line 1541 of file pixcomp.c.
References L_COPY, L_INSERT, pixacompAddBox(), pixacompAddPixcomp(), pixacompCreate(), pixacompGetBox(), pixacompGetBoxaCount(), pixacompGetCount(), and pixacompGetPixcomp().
[in] | pixacd | dest pixac; add to this one |
[in] | pixacs | [optional] source pixac; add from this one |
[in] | istart | starting index in pixacs |
[in] | iend | ending index in pixacs; use -1 to cat all |
Notes: (1) This appends a clone of each indicated pixc in pixcas to pixcad (2) istart < 0 is taken to mean 'read from the start' (istart = 0) (3) iend < 0 means 'read to the end' (4) If pixacs is NULL or contains no pixc, this is a no-op.
Definition at line 1490 of file pixcomp.c.
References boxaDestroy(), boxaJoin(), L_CLONE, L_COPY, L_NOCOPY, pixacompAddPixcomp(), pixacompGetBoxa(), pixacompGetBoxaCount(), pixacompGetCount(), and pixacompGetPixcomp().
PIXAC* pixacompRead | ( | const char * | filename | ) |
[in] | filename |
Notes: (1) Unlike the situation with serialized Pixa, where the image data is stored in png format, the Pixacomp image data can be stored in tiffg4, png and jpg formats.
Definition at line 1601 of file pixcomp.c.
References fopenReadStream(), and pixacompReadStream().
Referenced by pixaReadBoth().
PIXAC* pixacompReadMem | ( | const l_uint8 * | data, |
size_t | size | ||
) |
[in] | data | in pixacomp format |
[in] | size | of data |
Notes: (1) Deseralizes a buffer of pixacomp data into a pixac in memory.
Definition at line 1738 of file pixcomp.c.
References fopenReadFromMemory(), and pixacompReadStream().
PIXAC* pixacompReadStream | ( | FILE * | fp | ) |
[in] | fp | file stream |
Notes: (1) It is OK for the pixacomp to be empty.
Definition at line 1631 of file pixcomp.c.
References PIXACOMP_VERSION_NUMBER.
Referenced by pixacompRead(), and pixacompReadMem().
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[in] | pix | owned by the caller |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array. (2) The input pix is converted to a pixc, which is then inserted into the pixac.
Definition at line 1019 of file pixcomp.c.
References PixaComp::offset, and pixacompGetCount().
[in] | pixac | |
[in] | index | caller's view of index within pixac; includes offset |
[in] | pixc | to replace existing one, which is destroyed |
Notes: (1) The index includes the offset, which must be subtracted to get the actual index into the ptr array. (2) The inserted pixc is now owned by the pixac. The caller must not destroy it.
Definition at line 1062 of file pixcomp.c.
References L_NOCOPY, PixaComp::offset, pixacompGetCount(), pixacompGetPixcomp(), PixaComp::pixc, and pixcompDestroy().
l_ok pixacompSetOffset | ( | PIXAC * | pixac, |
l_int32 | offset | ||
) |
[in] | pixac | |
[in] | offset | non-negative |
Notes: (1) The offset is the difference between the caller's view of the index into the array and the actual array index. By default it is 0.
Definition at line 1406 of file pixcomp.c.
References PixaComp::offset.
Referenced by pixaCreateFromPixacomp().
l_ok pixacompWrite | ( | const char * | filename, |
PIXAC * | pixac | ||
) |
[in] | filename | |
[in] | pixac |
Notes: (1) Unlike the situation with serialized Pixa, where the image data is stored in png format, the Pixacomp image data can be stored in tiffg4, png and jpg formats.
Definition at line 1771 of file pixcomp.c.
References fopenWriteStream(), and pixacompWriteStream().
l_ok pixacompWriteFiles | ( | PIXAC * | pixac, |
const char * | subdir | ||
) |
[in] | pixac | |
[in] | subdir | subdirectory of /tmp |
Definition at line 2337 of file pixcomp.c.
References L_NOCOPY, lept_mkdir(), pixacompGetCount(), pixacompGetPixcomp(), and pixcompWriteFile().
l_ok pixacompWriteMem | ( | l_uint8 ** | pdata, |
size_t * | psize, | ||
PIXAC * | pixac | ||
) |
[out] | pdata | serialized data of pixac |
[out] | psize | size of serialized data |
[in] | pixac |
Notes: (1) Serializes a pixac in memory and puts the result in a buffer.
Definition at line 1846 of file pixcomp.c.
References fopenWriteWinTempfile(), l_binaryReadStream(), and pixacompWriteStream().
l_ok pixacompWriteStream | ( | FILE * | fp, |
PIXAC * | pixac | ||
) |
[in] | fp | file stream |
[in] | pixac |
Definition at line 1800 of file pixcomp.c.
References PixaComp::boxa, boxaWriteStream(), PixComp::cmapflag, PixComp::comptype, PixComp::d, PixComp::data, PixComp::h, L_NOCOPY, PixaComp::offset, PIXACOMP_VERSION_NUMBER, pixacompGetCount(), pixacompGetPixcomp(), PixComp::size, PixComp::w, PixComp::xres, and PixComp::yres.
Referenced by pixacompWrite(), and pixacompWriteMem().
l_ok pixacompWriteStreamInfo | ( | FILE * | fp, |
PIXAC * | pixac, | ||
const char * | text | ||
) |
[in] | fp | file stream |
[in] | pixac | |
[in] | text | [optional] identifying string; can be null |
Definition at line 2209 of file pixcomp.c.
References L_NOCOPY, PixaComp::nalloc, PixaComp::offset, pixacompGetBoxaCount(), pixacompGetCount(), pixacompGetPixcomp(), and pixcompWriteStreamInfo().
[in] | pixac | |
[in] | accesstype | L_COPY, L_CLONE, L_COPY_CLONE; for boxa |
Notes: (1) Because the pixa has no notion of offset, the offset must be set to 0 before the conversion, so that pixacompGetPix() fetches all the pixcomps. It is reset at the end.
Definition at line 1434 of file pixcomp.c.
References Pixa::boxa, boxaDestroy(), L_CLONE, L_COPY, L_COPY_CLONE, L_INSERT, pixaAddPix(), pixacompGetBoxa(), pixacompGetCount(), pixacompGetOffset(), pixacompGetPix(), pixacompSetOffset(), and pixaCreate().
Referenced by pixacompDisplayTiledAndScaled(), and pixaReadBoth().
[in] | pixcs |
Notes: (1) Limit the size of the compressed pix to 500 MB.
Definition at line 388 of file pixcomp.c.
References PixComp::size.
Referenced by pixacompAddPixcomp(), and pixacompGetPixcomp().
PIXC* pixcompCreateFromFile | ( | const char * | filename, |
l_int32 | comptype | ||
) |
[in] | filename | |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) Use comptype == IFF_DEFAULT to have the compression type automatically determined. (2) If the comptype is invalid for this file, the default will be substituted.
[in] | pix | |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
Notes: (1) Use comptype == IFF_DEFAULT to have the compression type automatically determined. (2) To compress jpeg with a quality other than the default (75), use l_jpegSetQuality()
PIXC* pixcompCreateFromString | ( | l_uint8 * | data, |
size_t | size, | ||
l_int32 | copyflag | ||
) |
[in] | data | compressed string |
[in] | size | number of bytes |
[in] | copyflag | L_INSERT or L_COPY |
Notes: (1) This works when the compressed string is png, jpeg or tiffg4. (2) The copyflag determines if the data in the new Pixcomp is a copy of the input data.
Definition at line 249 of file pixcomp.c.
References PixComp::cmapflag, PixComp::comptype, PixComp::d, PixComp::data, PixComp::h, l_binaryCopy(), L_COPY, L_INSERT, pixReadHeaderMem(), PixComp::size, and PixComp::w.
void pixcompDestroy | ( | PIXC ** | ppixc | ) |
[in,out] | ppixc | use ptr address so it will be nulled |
Notes: (1) Always nulls the input ptr.
Definition at line 356 of file pixcomp.c.
References PixComp::data, and PixComp::text.
Referenced by pixacompDestroy(), and pixacompReplacePixcomp().
l_ok pixcompDetermineFormat | ( | l_int32 | comptype, |
l_int32 | d, | ||
l_int32 | cmapflag, | ||
l_int32 * | pformat | ||
) |
[in] | comptype | IFF_DEFAULT, IFF_TIFF_G4, IFF_PNG, IFF_JFIF_JPEG |
[in] | d | pix depth |
[in] | cmapflag | 1 if pix to be compressed as a colormap; 0 otherwise |
[out] | pformat | IFF_TIFF, IFF_PNG or IFF_JFIF_JPEG |
Notes: (1) This determines the best format for a pix, given both the request (comptype) and the image characteristics. (2) If comptype == IFF_DEFAULT, this does not necessarily result in png encoding. Instead, it returns one of the three formats that is both valid and most likely to give best compression. (3) If d == 8 with no colormap and: * you wish to compress with png, use comptype == IFF_PNG * you wish to compress with jpeg, use either comptype == IFF_JFIF_JPEG or comptype == IFF_DEFAULT. (4) If the pix cannot be compressed by the input value of comptype, this selects IFF_PNG, which can compress all pix.
|
static |
[in] | pixc | containing images all at the same resolution |
[in] | title | [optional] pdf title |
[out] | pdata | output pdf data (of all images |
[out] | pnbytes | size of output pdf data |
Notes: (1) This generates the pdf without transcoding. (2) It assumes all images are jpeg encoded, have the same resolution, and that the resolution embedded in each jpeg file is correct. (It is transferred to the pdf via the cid.)
Definition at line 2171 of file pixcomp.c.
References cidConvertToPdfData(), PixComp::data, l_binaryCopy(), l_generateJpegDataMem(), and PixComp::size.
l_ok pixcompGetDimensions | ( | PIXC * | pixc, |
l_int32 * | pw, | ||
l_int32 * | ph, | ||
l_int32 * | pd | ||
) |
[in] | pixc | |
[out] | pw,ph,pd | [optional] |
Definition at line 435 of file pixcomp.c.
References PixComp::d, PixComp::h, and PixComp::w.
Referenced by pixacompGetPixDimensions().
l_ok pixcompGetParameters | ( | PIXC * | pixc, |
l_int32 * | pxres, | ||
l_int32 * | pyres, | ||
l_int32 * | pcomptype, | ||
l_int32 * | pcmapflag | ||
) |
[in] | pixc | |
[out] | pxres,pyres,pcomptype,pcmapflag | [optional] |
Definition at line 457 of file pixcomp.c.
References PixComp::cmapflag, PixComp::comptype, PixComp::xres, and PixComp::yres.
Referenced by pixacompFastConvertToPdfData().
l_ok pixcompWriteFile | ( | const char * | rootname, |
PIXC * | pixc | ||
) |
[in] | rootname | |
[in] | pixc |
Notes: (1) The compressed data is written to file, and the filename is generated by appending the format extension to rootname.
Definition at line 2375 of file pixcomp.c.
Referenced by pixacompWriteFiles().
l_ok pixcompWriteStreamInfo | ( | FILE * | fp, |
PIXC * | pixc, | ||
const char * | text | ||
) |
[in] | fp | file stream |
[in] | pixc | |
[in] | text | [optional] identifying string; can be null |
Definition at line 2251 of file pixcomp.c.
References PixComp::cmapflag, PixComp::comptype, PixComp::d, PixComp::h, PixComp::size, PixComp::w, PixComp::xres, and PixComp::yres.
Referenced by pixacompWriteStreamInfo().
[in] | pixc |
Definition at line 541 of file pixcomp.c.
References PixComp::d, PixComp::data, PixComp::h, pixGetDimensions(), pixReadMem(), pixSetResolution(), pixSetText(), PixComp::size, PixComp::text, PixComp::w, PixComp::xres, and PixComp::yres.
Referenced by pixacompGetPix().