NCEPLIBS-g2  3.4.7
dec_png.c File Reference

This program reads PNG stream data from memory. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <png.h>

Go to the source code of this file.

Typedefs

typedef int g2int
 Integer type. More...
 
typedef struct png_stream png_stream
 location to write PNG stream More...
 

Functions

int dec_png (unsigned char *pngbuf, g2int *width, g2int *height, char *cout)
 Decode some PNG compressed data. 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...
 

Detailed Description

This program reads PNG stream data from memory.

Author
Stephen Gilbert

Definition in file dec_png.c.

Typedef Documentation

◆ g2int

typedef int g2int

Integer type.

Definition at line 12 of file dec_png.c.

◆ png_stream

typedef struct png_stream png_stream

location to write PNG stream

Definition at line 12 of file dec_png.c.

Function Documentation

◆ dec_png()

int dec_png ( unsigned char *  pngbuf,
g2int width,
g2int height,
char *  cout 
)

Decode some PNG compressed data.

Parameters
pngbufPointer to the PNG buffer to be uncompressed.
widthPointer to the width.
heightPointer to the height.
coutPointer 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 64 of file dec_png.c.

References drstemplates::j, and user_read_data().

Referenced by pngunpack().

◆ 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_ptrPointer to PNG.
dataPointer to data.
lengthLength.
Author
Stephen Gilbert

Definition at line 34 of file dec_png.c.

Referenced by dec_png().