@@ -350,18 +350,18 @@ _png_module::read_png(const Py::Tuple& args)
350350 png_set_sig_bytes (png_ptr, 8 );
351351 png_read_info (png_ptr, info_ptr);
352352
353- png_uint_32 width = info_ptr-> width ;
354- png_uint_32 height = info_ptr-> height ;
353+ png_uint_32 width = png_get_image_width (png_ptr, info_ptr) ;
354+ png_uint_32 height = png_get_image_height (png_ptr, info_ptr) ;
355355
356- int bit_depth = info_ptr-> bit_depth ;
356+ int bit_depth = png_get_bit_depth (png_ptr, info_ptr) ;
357357
358358 // Unpack 1, 2, and 4-bit images
359359 if (bit_depth < 8 )
360360 png_set_packing (png_ptr);
361361
362362 // If sig bits are set, shift data
363363 png_color_8p sig_bit;
364- if ((info_ptr-> color_type != PNG_COLOR_TYPE_PALETTE) &&
364+ if ((png_get_color_type (png_ptr, info_ptr) != PNG_COLOR_TYPE_PALETTE) &&
365365 png_get_sBIT (png_ptr, info_ptr, &sig_bit))
366366 {
367367 png_set_shift (png_ptr, sig_bit);
@@ -374,13 +374,13 @@ _png_module::read_png(const Py::Tuple& args)
374374 }
375375
376376 // Convert palletes to full RGB
377- if (info_ptr-> color_type == PNG_COLOR_TYPE_PALETTE)
377+ if (png_get_color_type (png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE)
378378 {
379379 png_set_palette_to_rgb (png_ptr);
380380 }
381381
382382 // If there's an alpha channel convert gray to RGB
383- if (info_ptr-> color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
383+ if (png_get_color_type (png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA)
384384 {
385385 png_set_gray_to_rgb (png_ptr);
386386 }
@@ -408,11 +408,11 @@ _png_module::read_png(const Py::Tuple& args)
408408 npy_intp dimensions[3 ];
409409 dimensions[0 ] = height; // numrows
410410 dimensions[1 ] = width; // numcols
411- if (info_ptr-> color_type & PNG_COLOR_MASK_ALPHA)
411+ if (png_get_color_type (png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA)
412412 {
413413 dimensions[2 ] = 4 ; // RGBA images
414414 }
415- else if (info_ptr-> color_type & PNG_COLOR_MASK_COLOR)
415+ else if (png_get_color_type (png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR)
416416 {
417417 dimensions[2 ] = 3 ; // RGB images
418418 }
@@ -421,7 +421,8 @@ _png_module::read_png(const Py::Tuple& args)
421421 dimensions[2 ] = 1 ; // Greyscale images
422422 }
423423 // For gray, return an x by y array, not an x by y by 1
424- int num_dims = (info_ptr->color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2 ;
424+ int num_dims = (png_get_color_type (png_ptr, info_ptr)
425+ & PNG_COLOR_MASK_COLOR) ? 3 : 2 ;
425426
426427 double max_value = (1 << ((bit_depth < 8 ) ? 8 : bit_depth)) - 1 ;
427428 PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew (
0 commit comments