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