42 void *fld,
int fld_is_double,
int verbose)
45 g2int j, nbits, width, height;
46 float ref, bscale, dscale;
51 LOG((2,
"pngunpack_int len %ld ndpts %ld fld_is_double %d", len, ndpts, fld_is_double));
57 LOG((2,
"bscale %g dscale %g nbits %ld", bscale, dscale, nbits));
63 ifld = calloc(ndpts,
sizeof(
g2int));
64 ctemp = calloc(ndpts * 4, 1);
68 fprintf(stderr,
"Could not allocate space in jpcunpack.\n Data field NOT upacked.\n");
71 dec_png(cpack, &width, &height, ctemp);
72 gbits(ctemp, ifld, 0, nbits, 0, ndpts);
73 for (j = 0; j < ndpts; j++)
76 dfld[j] = (((double)ifld[j] * bscale) + ref) * dscale;
78 ffld[j] = (((float)ifld[j] * bscale) + ref) * dscale;
85 for (j = 0; j < ndpts; j++)
151 g2int len8 = len, ndpts8 = ndpts;
155 idrstmpl8[i] = idrstmpl[i];
157 return pngunpack_int(cpack, len8, idrstmpl8, ndpts8, fld, 0, 0);
183 g2int len8 = len, ndpts8 = ndpts;
187 idrstmpl8[i] = idrstmpl[i];
189 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)
Get bits - unpack bits: Extract arbitrary size values from a packed bit string, right justifying each...
#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)
This subroutine reads 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)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...