NCEPLIBS-g2c 2.0.0
Loading...
Searching...
No Matches
decenc_png.c File Reference

Decode/encode a PNG stream. More...

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

Go to the source code of this file.

Typedefs

typedef struct png_stream png_stream
 Typedef for PNG stream.
 

Functions

int dec_png (unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
 Decode PNG.
 
int enc_png (unsigned char *data, g2int width, g2int height, g2int nbits, unsigned char *pngbuf)
 Encode PNG.
 
void user_flush_data (png_structp png_ptr)
 Dummy Custom flush function.
 
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.
 
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.
 

Detailed Description

Decode/encode a PNG stream.

Author
Alyson Stahl
Date
2024-13-08

Definition in file decenc_png.c.

Typedef Documentation

◆ png_stream

typedef struct png_stream png_stream

Typedef for PNG stream.

Definition at line 21 of file decenc_png.c.

Function Documentation

◆ dec_png()

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

Decode PNG.

Parameters
pngbufPointer to PNG buffer.
widthPointer to width.
heightPointer to height.
coutOutput buffer.
Returns
0 for success, error code otherwise.
Author
Stephen Gilbert

Definition at line 100 of file decenc_png.c.

References user_read_data().

Referenced by pngunpack_int().

◆ enc_png()

int enc_png ( unsigned char *  data,
g2int  width,
g2int  height,
g2int  nbits,
unsigned char *  pngbuf 
)

Encode PNG.

Parameters
datadata.
widthwidth.
heightheight.
nbitsnumber of bits.
pngbufPNG buffer.
Returns
PNG length, or negative number for error.
Author
Stephen Gilbert

Definition at line 207 of file decenc_png.c.

References user_flush_data(), and user_write_data().

Referenced by pngpack_int().

◆ user_flush_data()

void user_flush_data ( png_structp  png_ptr)

Dummy Custom flush function.

Parameters
png_ptrPointer to PNG struct.
Author
Stephen Gilbert

Definition at line 83 of file decenc_png.c.

Referenced by enc_png().

◆ user_read_data()

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.

Parameters
png_ptrPointer to PNG.
dataPointer to data.
lengthLength.
Author
Stephen Gilbert

Definition at line 38 of file decenc_png.c.

Referenced by dec_png().

◆ user_write_data()

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.

Parameters
png_ptrpointer
datadata
lengthlength
Author
Stephen Gilbert

Definition at line 62 of file decenc_png.c.

Referenced by enc_png().