NCEPLIBS-g2c  1.6.4
pngpack.c File Reference

Function to pack data with PNG compression. More...

#include <stdlib.h>
#include <math.h>
#include "grib2.h"

Go to the source code of this file.

Functions

int enc_png (char *, g2int, g2int, g2int, char *)
 Encode PNG. More...
 
void pngpack (g2float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack)
 This subroutine packs up a data field into PNG image format. More...
 

Detailed Description

Function to pack data with PNG compression.

Author
Stephen Gilbert
Date
2003-08-27

Definition in file pngpack.c.

Function Documentation

◆ enc_png()

int enc_png ( char *  data,
g2int  width,
g2int  height,
g2int  nbits,
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 81 of file enc_png.c.

References user_flush_data(), and user_write_data().

Referenced by pngpack().

◆ pngpack()

void pngpack ( g2float fld,
g2int  width,
g2int  height,
g2int idrstmpl,
unsigned char *  cpack,
g2int lcpack 
)

This subroutine packs up a data field into PNG image format.

After the data field is scaled, and the reference value is subtracted out, it is treated as a grayscale image and passed to a PNG encoder. It also fills in GRIB2 Data Representation Template 5.41 or 5.40010 with the appropriate values.

Parameters
fldContains the data values to pack.
widthnumber of points in the x direction.
heightnumber of points in the y direction.
idrstmplContains the array of values for Data Representation Template 5.41 or 5.40010.
  • 0 Reference value - ignored on input, set by pngpack routine.
  • 1 Binary Scale Factor - used on input.
  • 2 Decimal Scale Factor - used on input.
  • 3 number of bits for each grayscale pixel value - ignored on input.
  • 4 Original field type - currently ignored on input, set = 0 on output. Data values assumed to be reals.
cpackThe packed data field.
lcpacklength of packed field cpack.
Author
Stephen Gilbert
Date
2003-08-27

Definition at line 38 of file pngpack.c.

References enc_png(), int_power(), mkieee(), and sbits().

Referenced by g2_addfield().