These functions read/write PNG stream to/from memory.
More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <png.h>
Go to the source code of this file.
|
| typedef int | g2int |
| | Integer type.
|
| |
| typedef struct png_stream | png_stream |
| | location to write PNG stream
|
| |
|
| int | dec_png (unsigned char *pngbuf, g2int *width, g2int *height, char *cout) |
| | Decode some PNG compressed data.
|
| |
| int | enc_png (char *data, g2int *width, g2int *height, g2int *nbits, char *pngbuf) |
| | create png_structs to write png stream into memory.
|
| |
| static void | user_flush_data (png_structp png_ptr) |
| | Dummy Custom flush function.
|
| |
| static void | user_read_data (png_structp png_ptr, png_bytep data, png_uint_32 length) |
| | Custom read function used so that libpng will read a PNG stream from memory instead of a file on disk.
|
| |
| static void | user_write_data (png_structp png_ptr, png_bytep data, png_uint_32 length) |
| | Custom write function used to that libpng will write to memory location instead of a file on disk.
|
| |
These functions read/write PNG stream to/from memory.
- Author
- Ed Hartnett
- Date
- 3/5/24
Definition in file g2cpng.c.
◆ g2int
Integer type.
Definition at line 12 of file g2cpng.c.
◆ png_stream
| typedef struct png_stream png_stream |
location to write PNG stream
Definition at line 21 of file g2cpng.c.
◆ dec_png()
| int dec_png |
( |
unsigned char * |
pngbuf, |
|
|
g2int * |
width, |
|
|
g2int * |
height, |
|
|
char * |
cout |
|
) |
| |
Decode some PNG compressed data.
- Parameters
-
| pngbuf | Pointer to the PNG buffer to be uncompressed. |
| width | Pointer to the width. |
| height | Pointer to the height. |
| cout | Pointer that gets the unpacked data. |
- Returns
- 0 Success
- -1 Error initializing PNG structs.
- -2 Error initializing PNG info struct.
- -3 Error initializing PNG error callbacks, or stream not valid PNG.
- Author
- Stephen Gilbert
Definition at line 188 of file g2cpng.c.
References user_read_data().
Referenced by pngunpack().
◆ enc_png()
| int enc_png |
( |
char * |
data, |
|
|
g2int * |
width, |
|
|
g2int * |
height, |
|
|
g2int * |
nbits, |
|
|
char * |
pngbuf |
|
) |
| |
create png_structs to write png stream into memory.
- Parameters
-
| data | data. |
| width | width. |
| height | height. |
| nbits | number of bits. |
| pngbuf | PNG buffer. |
- Returns
- pnglen the length of png stream
- Author
- Stephen Gilbert
Definition at line 74 of file g2cpng.c.
References user_flush_data(), and user_write_data().
Referenced by pngpack().
◆ user_flush_data()
| static void user_flush_data |
( |
png_structp |
png_ptr | ) |
|
|
static |
Dummy Custom flush function.
- Parameters
-
| png_ptr | Pointer to PNG struct. |
- Author
- Stephen Gilbert
Definition at line 57 of file g2cpng.c.
Referenced by enc_png().
◆ user_read_data()
| static void user_read_data |
( |
png_structp |
png_ptr, |
|
|
png_bytep |
data, |
|
|
png_uint_32 |
length |
|
) |
| |
|
static |
Custom read function used so that libpng will read a PNG stream from memory instead of a file on disk.
- Parameters
-
| png_ptr | Pointer to PNG. |
| data | Pointer to data. |
| length | Length. |
- Author
- Stephen Gilbert
Definition at line 158 of file g2cpng.c.
Referenced by dec_png().
◆ user_write_data()
| static void user_write_data |
( |
png_structp |
png_ptr, |
|
|
png_bytep |
data, |
|
|
png_uint_32 |
length |
|
) |
| |
|
static |
Custom write function used to that libpng will write to memory location instead of a file on disk.
- Parameters
-
| png_ptr | pointer |
| data | data |
| length | length |
- Author
- Stephen Gilbert
Definition at line 35 of file g2cpng.c.
Referenced by enc_png().