@@ -350,18 +350,18 @@ _png_module::read_png(const Py::Tuple& args)
350
350
png_set_sig_bytes (png_ptr, 8 );
351
351
png_read_info (png_ptr, info_ptr);
352
352
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) ;
355
355
356
- int bit_depth = info_ptr-> bit_depth ;
356
+ int bit_depth = png_get_bit_depth (png_ptr, info_ptr) ;
357
357
358
358
// Unpack 1, 2, and 4-bit images
359
359
if (bit_depth < 8 )
360
360
png_set_packing (png_ptr);
361
361
362
362
// If sig bits are set, shift data
363
363
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) &&
365
365
png_get_sBIT (png_ptr, info_ptr, &sig_bit))
366
366
{
367
367
png_set_shift (png_ptr, sig_bit);
@@ -374,13 +374,13 @@ _png_module::read_png(const Py::Tuple& args)
374
374
}
375
375
376
376
// 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)
378
378
{
379
379
png_set_palette_to_rgb (png_ptr);
380
380
}
381
381
382
382
// 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)
384
384
{
385
385
png_set_gray_to_rgb (png_ptr);
386
386
}
@@ -408,11 +408,11 @@ _png_module::read_png(const Py::Tuple& args)
408
408
npy_intp dimensions[3 ];
409
409
dimensions[0 ] = height; // numrows
410
410
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)
412
412
{
413
413
dimensions[2 ] = 4 ; // RGBA images
414
414
}
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)
416
416
{
417
417
dimensions[2 ] = 3 ; // RGB images
418
418
}
@@ -421,7 +421,8 @@ _png_module::read_png(const Py::Tuple& args)
421
421
dimensions[2 ] = 1 ; // Greyscale images
422
422
}
423
423
// 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 ;
425
426
426
427
double max_value = (1 << ((bit_depth < 8 ) ? 8 : bit_depth)) - 1 ;
427
428
PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew (
0 commit comments