---
name: "pngunpack.c"
section: "3"
platform: "linux"
package: "libg2c-dev"
version: "2.1.0-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/pngunpack.c"
---

# pngunpack.c(3)

Unpack data packed with PNG compression.

## NAME

pngunpack.c - Unpack data packed with PNG compression.

## SYNOPSIS

`#include 'grib2_int.h'`\
 `#include <stdio.h>`\
 `#include <stdlib.h>`\

### Functions

int **g2c\_pngunpackd** (unsigned char \*cpack, size\_t len, int \*idrstmpl, size\_t ndpts, double \*fld)\
 This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.  int **g2c\_pngunpackf** (unsigned char \*cpack, size\_t len, int \*idrstmpl, size\_t ndpts, float \*fld)\
 This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.  **g2int** **pngunpack** (unsigned char \*cpack, **g2int** len, **g2int** \*idrstmpl, **g2int** ndpts, float \*fld)\
 This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.  static int **pngunpack\_int** (unsigned char \*cpack, **g2int** len, **g2int** \*idrstmpl, **g2int** ndpts, void \*fld, int fld\_is\_double, int verbose)\
 Unpack a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.

## Detailed Description

Unpack data packed with PNG compression.

**Author**

Stephen Gilbert

**Date**

2003-08-27

Definition in file **pngunpack.c**.

## Function Documentation

### int g2c\_pngunpackd (unsigned char \* cpack, size\_t len, int \* idrstmpl, size\_t ndpts, double \* fld)

This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.

**Parameters**

*cpack* The packed data field (character\*1 array). \
 *len* length of packed field cpack(). \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.41` or 5.40010. \
 *ndpts* The number of data values to unpack. \
 *fld* Contains the unpacked data values.

**Returns**

- •

  **G2C\_NOERROR** No Error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Ed Hartnett

**Date**

Aug 8, 2022

Definition at line **188** of file **pngunpack.c**.

References **G2C\_PNG\_DRS\_TEMPLATE\_LEN**, and **pngunpack\_int()**.

### int g2c\_pngunpackf (unsigned char \* cpack, size\_t len, int \* idrstmpl, size\_t ndpts, float \* fld)

This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.

**Parameters**

*cpack* The packed data field (character\*1 array). \
 *len* length of packed field cpack(). \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.41` or 5.40010. \
 *ndpts* The number of data values to unpack. \
 *fld* Contains the unpacked data values.

**Returns**

- •

  **G2C\_NOERROR** No Error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Ed Hartnett

**Date**

Sep 8, 2022

Definition at line **156** of file **pngunpack.c**.

References **G2C\_PNG\_DRS\_TEMPLATE\_LEN**, and **pngunpack\_int()**.

### g2int pngunpack (unsigned char \* cpack, g2int len, g2int \* idrstmpl, g2int ndpts, float \* fld)

This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.

**Parameters**

*cpack* The packed data field (character\*1 array). \
 *len* length of packed field cpack(). \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.41` or 5.40010. \
 *ndpts* The number of data values to unpack. \
 *fld* Contains the unpacked data values.

**Returns**

- •

  **G2C\_NOERROR** No error.

- •

  **G2\_JPCUNPACK\_MEM** Out of memory.

**Author**

Stephen Gilbert

**Date**

2003-08-27

**Author**

Ed Hartnett

Definition at line **126** of file **pngunpack.c**.

References **G2\_JPCUNPACK\_MEM**, **G2C\_ENOMEM**, and **pngunpack\_int()**.

Referenced by **g2c\_unpack7\_int()**.

### static int pngunpack\_int (unsigned char \* cpack, g2int len, g2int \* idrstmpl, g2int ndpts, void \* fld, int fld\_is\_double, int verbose)` [static]`

Unpack a data field that was packed into a PNG image format using info from the GRIB2 Data Representation Template 5.41 or 5.40010.

**Parameters**

*cpack* The packed data field (character\*1 array). \
 *len* The length of packed field cpack(). \
 *idrstmpl* Pointer to array of values for Data Representation `Template 5.41` or 5.40010. \
 *ndpts* The number of data values to unpack. \
 *fld* Pointer that will get the unpacked data values. \
 *fld\_is\_double* If non-zero, then fld will get data as double, otherwise float. \
 *verbose* If non-zero, error messages will be printed in case of error. Otherwise, error codes will be return but no error messages printed. Calls to the original g2c API may cause error messages to be printed in case of error. For the new g2c\_ API, no error messages will be printed - instead an error code will be returned. Call **g2c\_strerror()** to get the error message for any error code.

**Returns**

- •

  **G2C\_NOERROR** No Error.

- •

  **G2C\_ENOMEM** Out of memory.

**Author**

Stephen Gilbert, Ed Hartnett

**Date**

Aug 8, 2022

Definition at line **40** of file **pngunpack.c**.

References **dec\_png()**, **G2C\_ENOMEM**, **gbits()**, **int\_power()**, **LOG**, and **rdieee()**.

Referenced by **g2c\_pngunpackd()**, **g2c\_pngunpackf()**, and **pngunpack()**.

## Author

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code.
