Skip to content

Commit

Permalink
fix C example libpng usage
Browse files Browse the repository at this point in the history
    - thanks to nickmeinhold for finding and reporting the fix!
  • Loading branch information
spadix0 committed Sep 18, 2011
1 parent 6e9910a commit 0accb61
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion examples/scan_image.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
#include <png.h>
#include <zbar.h>

#if !defined(PNG_LIBPNG_VER) || \
PNG_LIBPNG_VER < 10018 || \
(PNG_LIBPNG_VER > 10200 && \
PNG_LIBPNG_VER < 10209)
/* Changes to Libpng from version 1.2.42 to 1.4.0 (January 4, 2010)
* ...
* 2. m. The function png_set_gray_1_2_4_to_8() was removed. It has been
* deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
* png_set_expand_gray_1_2_4_to_8() because the former function also
* expanded palette images.
*/
# define png_set_expand_gray_1_2_4_to_8 png_set_gray_1_2_4_to_8
#endif

zbar_image_scanner_t *scanner = NULL;

/* to complete a runnable example, this abbreviated implementation of
Expand Down Expand Up @@ -30,7 +44,7 @@ static void get_data (const char *name,
if(color & PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png);
if(color == PNG_COLOR_TYPE_GRAY && bits < 8)
png_set_gray_1_2_4_to_8(png);
png_set_expand_gray_1_2_4_to_8(png);
if(bits == 16)
png_set_strip_16(png);
if(color & PNG_COLOR_MASK_ALPHA)
Expand Down

0 comments on commit 0accb61

Please sign in to comment.