41 void *fld,
int fld_is_double,
int verbose)
44 g2int j, nbits, width, height;
45 float ref, bscale, dscale;
50 LOG((2,
"pngunpack_int len %ld ndpts %ld fld_is_double %d", len, ndpts, fld_is_double));
56 LOG((2,
"bscale %g dscale %g nbits %ld", bscale, dscale, nbits));
62 ifld = calloc(ndpts,
sizeof(
g2int));
63 ctemp = calloc(ndpts * 4, 1);
67 fprintf(stderr,
"Could not allocate space in jpcunpack.\n Data field NOT upacked.\n");
70 dec_png(cpack, &width, &height, ctemp);
71 gbits(ctemp, ifld, 0, nbits, 0, ndpts);
72 for (j = 0; j < ndpts; j++)
75 dfld[j] = (((double)ifld[j] * bscale) + ref) * dscale;
77 ffld[j] = (((float)ifld[j] * bscale) + ref) * dscale;
84 for (j = 0; j < ndpts; j++)
150 g2int len8 = len, ndpts8 = ndpts;
154 idrstmpl8[i] = idrstmpl[i];
156 return pngunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 0, 0);
182 g2int len8 = len, ndpts8 = ndpts;
186 idrstmpl8[i] = idrstmpl[i];
188 return pngunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 1, 0);
int dec_png(unsigned char *pngbuf, g2int *width, g2int *height, unsigned char *cout)
Decode PNG.
void gbits(unsigned char *in, g2int *iout, g2int iskip, g2int nbits, g2int nskip, g2int n)
Unpack arbitrary size values from a packed bit string, right justifying each value in the unpacked io...
#define G2C_ENOMEM
Out of memory.
#define G2C_PNG_DRS_TEMPLATE_LEN
Length of the idrstmpl array for PNG packing.
#define G2_JPCUNPACK_MEM
In jpcunpack() or other unpack function: out of memory.
int64_t g2int
Long integer type.
Header file with internal function prototypes NCEPLIBS-g2c library.
double int_power(double x, g2int y)
Function similar to C pow() power function.
#define LOG(e)
Ignore logging to stdout.
void rdieee(g2int *rieee, float *a, g2int num)
Read a list of real values in 32-bit IEEE floating point format.
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 GRIB...
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 GRIB...
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 GRIB...
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 Representa...