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.
|
int | dec_png (unsigned char *pngbuf, g2int *width, g2int *height, char *cout) |
| Decode some PNG compressed data. More...
|
|
int | enc_png (char *data, g2int *width, g2int *height, g2int *nbits, char *pngbuf) |
| create png_structs to write png stream into memory. More...
|
|
static void | user_flush_data (png_structp png_ptr) |
| Dummy Custom flush function. More...
|
|
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. More...
|
|
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. More...
|
|
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 12 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 drstemplates::j, and user_read_data().
Referenced by pngunpack().
◆ enc_png()
int enc_png |
( |
char * |
data, |
|
|
g2int * |
width, |
|
|
g2int * |
height, |
|
|
g2int * |
nbits, |
|
|
char * |
pngbuf |
|
) |
| |
◆ 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().