Image-Leptonica
view release on metacpan or search on metacpan
lib/Image/Leptonica/Func/pngio.pm view on Meta::CPAN
The default is TRUE, which causes pixRead() to strip each 16 bit
sample down to 8 bps:
- For 16 bps rgb (16 bps, 3 spp) --> 32 bpp rgb Pix
- For 16 bps gray (16 bps, 1 spp) --> 8 bpp grayscale Pix
If the variable is set to FALSE, the 16 bit gray samples
are saved when read; the 16 bit rgb samples return an error.
Note: results can be non-deterministic if used with
multi-threaded applications.
On systems like windows without fmemopen() and open_memstream(),
we write data to a temp file and read it back for operations
between pix and compressed-data, such as pixReadMemPng() and
pixWriteMemPng().
=head1 FUNCTIONS
=head2 fgetPngResolution
l_int32 fgetPngResolution ( FILE *fp, l_int32 *pxres, l_int32 *pyres )
fgetPngResolution()
Input: stream (opened for read)
&xres, &yres (<return> resolution in ppi)
Return: 0 if OK; 0 on error
Notes:
(1) If neither resolution field is set, this is not an error;
the returned resolution values are 0 (designating 'unknown').
(2) Side-effect: this rewinds the stream.
=head2 freadHeaderPng
l_int32 freadHeaderPng ( FILE *fp, l_int32 *pw, l_int32 *ph, l_int32 *pbps, l_int32 *pspp, l_int32 *piscmap )
freadHeaderPng()
Input: stream
&w (<optional return>)
&h (<optional return>)
&bps (<optional return>, bits/sample)
&spp (<optional return>, samples/pixel)
&iscmap (<optional return>)
Return: 0 if OK, 1 on error
Notes:
(1) See readHeaderPng().
=head2 l_pngSetReadStrip16To8
void l_pngSetReadStrip16To8 ( l_int32 flag )
l_pngSetReadStrip16To8()
Input: flag (1 for stripping 16 bpp to 8 bpp on reading;
0 for leaving 16 bpp)
Return: void
=head2 pixReadMemPng
PIX * pixReadMemPng ( const l_uint8 *cdata, size_t size )
pixReadMemPng()
Input: cdata (const; png-encoded)
size (of data)
Return: pix, or null on error
Notes:
(1) The @size byte of @data must be a null character.
=head2 pixReadStreamPng
PIX * pixReadStreamPng ( FILE *fp )
pixReadStreamPng()
Input: stream
Return: pix, or null on error
Notes:
(1) If called from pixReadStream(), the stream is positioned
at the beginning of the file.
(2) To do sequential reads of png format images from a stream,
use pixReadStreamPng()
(3) Grayscale-with-alpha pngs (spp = 2) are converted to RGBA
on read; the returned pix has spp = 4 and equal red, green and
blue channels.
(4) spp = 1 with alpha (palette) is converted to RGBA with spp = 4.
(5) We use the high level png interface, where the transforms are set
up in advance and the header and image are read with a single
call. The more complicated interface, where the header is
read first and the buffers for the raster image are user-
allocated before reading the image, works OK for single images,
but I could not get it to work properly for the successive
png reads that are required by pixaReadStream().
=head2 pixSetZlibCompression
l_int32 pixSetZlibCompression ( PIX *pix, l_int32 compval )
pixSetZlibCompression()
Input: pix
compval (zlib compression value)
Return: 0 if OK, 1 on error
Notes:
(1) Valid zlib compression values are in the interval [0 ... 9],
where, as defined in zlib.h:
0 Z_NO_COMPRESSION
1 Z_BEST_SPEED (poorest compression)
9 Z_BEST_COMPRESSION
For the default value, use either of these:
6 Z_DEFAULT_COMPRESSION
-1 (resolves to Z_DEFAULT_COMPRESSION)
(2) If you use the defined constants in zlib.h instead of the
compression integers given above, you must include zlib.h.
=head2 pixWriteMemPng
l_int32 pixWriteMemPng ( l_uint8 **pdata, size_t *psize, PIX *pix, l_float32 gamma )
pixWriteMemPng()
( run in 1.960 second using v1.01-cache-2.11-cpan-140bd7fdf52 )