pngpack.c(3)

πŸ“¦
version 2.3.0 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– pngpack.c(3) β€” Library Functions Manual πŸ’–

okay bestie, gather round, because today we're talking about pngpack.c from the NCEPLIBS-g2c family, and honestly? it's giving compression icon. she packs data with PNG compression and she does it with main character energy. let's go. ✨


🌸 NAME 🌸

pngpack.c β€” Pack data with PNG compression. that's it, that's the whole vibe. short, sweet, slays. πŸ’…


✨ SYNOPSIS ✨

first things first, the incantations. you gotta summon these headers or nothing works, no cap:

#include 'grib2_int.h'
#include <math.h>
#include <stdlib.h>

πŸ¦‹ Functions

here's the whole squad. four functions, all of them absolute legends:

  • int g2c_pngpackd (double *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack) β€” This subroutine packs up a double data field into PNG image format. (double girlies, this one's for you 🫢)
  • int g2c_pngpackf (float *fld, size_t width, size_t height, int *idrstmpl, unsigned char *cpack, int *lcpack) β€” This subroutine packs up a float data field into PNG image format. (float girlies, same energy)
  • void pngpack (float *fld, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack) β€” This subroutine packs up a float data field into PNG image format. (the OG, the classic, the moment)
  • static int pngpack_int (void *fld, int fld_is_double, g2int width, g2int height, g2int *idrstmpl, unsigned char *cpack, g2int *lcpack, int verbose) β€” Packs float or double data into PNG image format. (the one doing all the actual work behind the scenes, lowkey the backbone of the friend group)

πŸŽ€ Detailed Description πŸŽ€

Pack data with PNG compression.

that's the whole thesis statement bestie. data goes in, PNG compression happens, iconic behavior ensues.

Author Stephen Gilbert

Date 2003-08-27

Definition in file pngpack.c.


πŸ‘‘ Function Documentation πŸ‘‘

πŸ“ int g2c_pngpackd (double * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, int * lcpack)

This subroutine packs up a double data field into PNG image format. okay so here's the tea: 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. like, she does it ALL. πŸ’…

Parameters

  • fld β€” Pointer to array of double that contains the data values to pack.
  • width β€” Number of points in the x direction.
  • height β€” Number of points in the y direction.
  • idrstmpl β€” Contains 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.
  • cpack β€” The packed data field.
  • lcpack β€” length of packed field cpack.

Returns

  • G2C_NOERROR β€” No error. πŸŽ‰
  • G2C_EPNG β€” Error encoding/decoding PNG data. 😭

Author Ed Hartnett

Date Aug 8, 2022

Definition at line 348 of file pngpack.c.

References G2C_PNG_DRS_TEMPLATE_LEN, and pngpack_int().


🌈 int g2c_pngpackf (float * fld, size_t width, size_t height, int * idrstmpl, unsigned char * cpack, int * lcpack)

This subroutine packs up a float data field into PNG image format. same storyline, float edition: 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. obsessed fr fr.

Parameters

  • fld β€” Pointer to array of float that contains the data values to pack.
  • width β€” Number of points in the x direction.
  • height β€” Number of points in the y direction.
  • idrstmpl β€” Contains 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.
  • cpack β€” The packed data field.
  • lcpack β€” length of packed field cpack.

Returns

  • G2C_NOERROR β€” No error. πŸŽ‰
  • G2C_EPNG β€” Error encoding/decoding PNG data. 😭

Author Ed Hartnett

Definition at line 294 of file pngpack.c.

References G2C_PNG_DRS_TEMPLATE_LEN, and pngpack_int().


πŸ’œ void pngpack (float * fld, g2int width, g2int height, g2int * idrstmpl, unsigned char * cpack, g2int * lcpack)

This subroutine packs up a float data field into PNG image format. the classic!! 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. she's been doing this since 2003 and she's still that girl. πŸ‘‘

Parameters

  • fld β€” Pointer to array of float that contains the data values to pack.
  • width β€” Number of points in the x direction.
  • height β€” Number of points in the y direction.
  • idrstmpl β€” Contains 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.
  • cpack β€” The packed data field.
  • lcpack β€” length of packed field cpack.

Author Stephen Gilbert

Date 2003-08-27

Author Ed Hartnett

Definition at line 254 of file pngpack.c.

References pngpack_int().

Referenced by g2_addfield().


🧚 int pngpack_int (void * fld, int fld_is_double, g2int width, g2int height, g2int * idrstmpl, unsigned char * cpack, g2int * lcpack, int verbose)

[static]

Packs float or double data into PNG image format. this is called by pngpack() and pngpackd(). she's the intern that's actually running the whole company, iykyk. 🫢

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

  • fld β€” Pointer to array of float or double that contains the data values to pack.
  • fld_is_double β€” If non-zero, then fld is double, otherwise float.
  • width β€” Number of points in the x direction. This is passed to the PNG layer as a uint32.
  • height β€” Number of points in the y direction. This is passed to the PNG layer as a uint32.
  • idrstmpl β€” Contains 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.
  • cpack β€” The packed data field.
  • lcpack β€” length of packed field cpack.
  • 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_EPNG β€” Error encoding/decoding PNG data. 😭

Author Ed Hartnett

Date Aug 8, 2022

Definition at line 53 of file pngpack.c.

References ALOG2, enc_png(), G2C_EPNG, G2C_NOERROR, int_power(), LOG, mkieee(), and sbits().

Referenced by g2c_pngpackd(), g2c_pngpackf(), and pngpack().


πŸ’– Author πŸ’–

Generated automatically by Doxygen for NCEPLIBS-g2c from the source code. (yes bestie, a robot wrote the docs, but the vibes? those are all mine. πŸ™ˆ)


okay and that's the whole page!! no notes, ate and left no crumbs, periodt. πŸŽ€

NCEPLIBS-g2c, Version 2.3.0, and our girl pngpack.c(3) β€” mwah, love that for us. go forth and pack some PNGs, bestie, you've got this. πŸ’…βœ¨πŸ¦‹πŸŒΈπŸ’œ

πŸ“¦ where this page comes from