Re: [Sng-devel] sng 1.0.5 vs libpng 1.4
Textualize a PNG image, or turn a textualized image back to a PNG.
Brought to you by:
esr
From: Eric R. <es...@th...> - 2011-06-15 19:29:15
|
Here's my first cut at coping with the API problem. Compiles here. diff --git a/sngd.c b/sngd.c index 248ac97..1ab5727 100644 --- a/sngd.c +++ b/sngd.c @@ -12,6 +12,21 @@ NAME #include "png.h" #include "sng.h" +/* cope with API issues */ +#if PNG_LIBPNG_VER_MAJOR == 1 + #if PNG_LIBPNG_VER_MINOR <= 2 + #define TRANS_COLOR trans_values + #define TRANS_ALPHA trans + #endif + #if PNG_LIBPNG_VER_MINOR == 3 + #error Not yet ported to 1.3 + #endif + #if PNG_LIBPNG_VER_MINOR >= 4 + #define TRANS_COLOR trans_color + #define TRANS_ALPHA trans_alpha + #endif +#endif + png_structp png_ptr; png_infop info_ptr; @@ -794,17 +809,17 @@ static void dump_tRNS(FILE *fpout) fprintf(fpout, "tRNS {\n"); switch (info_ptr->color_type) { case PNG_COLOR_TYPE_GRAY: - fprintf(fpout, " gray: %u;\n", info_ptr->trans_values.gray); + fprintf(fpout, " gray: %u;\n", info_ptr->TRANS_COLOR.gray); break; case PNG_COLOR_TYPE_RGB: fprintf(fpout, " red: %u; green: %u; blue: %u;\n", - info_ptr->trans_values.red, - info_ptr->trans_values.green, - info_ptr->trans_values.blue); + info_ptr->TRANS_COLOR.red, + info_ptr->TRANS_COLOR.green, + info_ptr->TRANS_COLOR.blue); break; case PNG_COLOR_TYPE_PALETTE: for (i = 0; i < info_ptr->num_trans; i++) - fprintf(fpout, " %u", info_ptr->trans[i]); + fprintf(fpout, " %u", info_ptr->TRANS_ALPHA[i]); break; case PNG_COLOR_TYPE_GRAY_ALPHA: case PNG_COLOR_TYPE_RGB_ALPHA: -- <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> |