@@ -351,18 +351,18 @@ _png_module::read_png(const Py::Tuple& args)
351351 png_set_sig_bytes (png_ptr, 8 );
352352 png_read_info (png_ptr, info_ptr);
353353
354- png_uint_32 width = info_ptr-> width ;
355- png_uint_32 height = info_ptr-> height ;
354+ png_uint_32 width = png_get_image_width (png_ptr, info_ptr) ;
355+ png_uint_32 height = png_get_image_height (png_ptr, info_ptr) ;
356356
357- int bit_depth = info_ptr-> bit_depth ;
357+ int bit_depth = png_get_bit_depth (png_ptr, info_ptr) ;
358358
359359 // Unpack 1, 2, and 4-bit images
360360 if (bit_depth < 8 )
361361 png_set_packing (png_ptr);
362362
363363 // If sig bits are set, shift data
364364 png_color_8p sig_bit;
365- if ((info_ptr-> color_type != PNG_COLOR_TYPE_PALETTE) &&
365+ if ((png_get_color_type (png_ptr, info_ptr) != PNG_COLOR_TYPE_PALETTE) &&
366366 png_get_sBIT (png_ptr, info_ptr, &sig_bit))
367367 {
368368 png_set_shift (png_ptr, sig_bit);
@@ -375,13 +375,13 @@ _png_module::read_png(const Py::Tuple& args)
375375 }
376376
377377 // Convert palletes to full RGB
378- if (info_ptr-> color_type == PNG_COLOR_TYPE_PALETTE)
378+ if (png_get_color_type (png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE)
379379 {
380380 png_set_palette_to_rgb (png_ptr);
381381 }
382382
383383 // If there's an alpha channel convert gray to RGB
384- if (info_ptr-> color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
384+ if (png_get_color_type (png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA)
385385 {
386386 png_set_gray_to_rgb (png_ptr);
387387 }
@@ -409,11 +409,11 @@ _png_module::read_png(const Py::Tuple& args)
409409 npy_intp dimensions[3 ];
410410 dimensions[0 ] = height; // numrows
411411 dimensions[1 ] = width; // numcols
412- if (info_ptr-> color_type & PNG_COLOR_MASK_ALPHA)
412+ if (png_get_color_type (png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA)
413413 {
414414 dimensions[2 ] = 4 ; // RGBA images
415415 }
416- else if (info_ptr-> color_type & PNG_COLOR_MASK_COLOR)
416+ else if (png_get_color_type (png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR)
417417 {
418418 dimensions[2 ] = 3 ; // RGB images
419419 }
@@ -422,7 +422,8 @@ _png_module::read_png(const Py::Tuple& args)
422422 dimensions[2 ] = 1 ; // Greyscale images
423423 }
424424 // For gray, return an x by y array, not an x by y by 1
425- int num_dims = (info_ptr->color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2 ;
425+ int num_dims = (png_get_color_type (png_ptr, info_ptr)
426+ & PNG_COLOR_MASK_COLOR) ? 3 : 2 ;
426427
427428 double max_value = (1 << ((bit_depth < 8 ) ? 8 : bit_depth)) - 1 ;
428429 PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew (
0 commit comments