1 /*****************************************************************************
2 * RRDtool 1.4.3 Copyright by Tobi Oetiker, 1997-2010
3 *****************************************************************************
4 * pngsize.c determine the size of a PNG image
5 *****************************************************************************/
15 png_structp png_read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
17 /* we would need to point to error handlers
18 here to do it properly */
20 (png_error_ptr) NULL);
22 png_infop info_ptr = png_create_info_struct(png_read_ptr);
27 /* this is to make compile on aix work since they seem to define jmpbuf
28 to be _jmpbuf which breaks compilation */
31 #ifdef PNG_SETJMP_SUPPORTED
32 # define png_jmpbuf(png_ptr) ((png_ptr)->PNG_jmpbuf)
37 # define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
41 if (setjmp(png_jmpbuf(png_read_ptr))) {
42 png_destroy_read_struct(&png_read_ptr, &info_ptr, (png_infopp) NULL);
46 png_init_io(png_read_ptr, fd);
47 png_read_info(png_read_ptr, info_ptr);
48 (*width) = png_get_image_width(png_read_ptr, info_ptr);
49 (*height) = png_get_image_height(png_read_ptr, info_ptr);
51 png_destroy_read_struct(&png_read_ptr, &info_ptr, NULL);
52 if (*width > 0 && *height > 0)