build matplotlib1.0.1 with libpng.1.5.2

hi list,

first, thanks for providing matplotlib, i am using it in several projects.

i had problems with several png files and decided to upgrade libpng.
this broke matplotlib.
as you can see in the documentation of libpng15, it is no longer possible
to directly access png_infop.

i have created the following patch:

--- matplotlib-1.0.1/src/_png.cpp 2010-10-12 16:14:42.000000000 +0000
+++ matplotlib-1.0.1X/src/_png.cpp 2011-05-25 19:23:36.261752651 +0000
@@ -350,18 +350,21 @@
     png_set_sig_bytes(png_ptr, 8);
     png_read_info(png_ptr, info_ptr);

- png_uint_32 width = info_ptr->width;
- png_uint_32 height = info_ptr->height;
+ png_uint_32 width = png_get_image_width(png_ptr, info_ptr);
+ png_uint_32 height = png_get_image_height(png_ptr, info_ptr);

- int bit_depth = info_ptr->bit_depth;
+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr);

     // Unpack 1, 2, and 4-bit images
     if (bit_depth < 8)
         png_set_packing(png_ptr);

+ // this is needed several times, so safe it in a variable
+ png_byte color_type = png_get_color_type(png_ptr, info_ptr);

···

+
     // If sig bits are set, shift data
     png_color_8p sig_bit;
- if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) &&
+ if ((color_type != PNG_COLOR_TYPE_PALETTE) &&
         png_get_sBIT(png_ptr, info_ptr, &sig_bit))
     {
         png_set_shift(png_ptr, sig_bit);
@@ -374,13 +377,13 @@
     }

     // Convert palletes to full RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
     {
         png_set_palette_to_rgb(png_ptr);
     }

     // If there's an alpha channel convert gray to RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
     {
         png_set_gray_to_rgb(png_ptr);
     }
@@ -408,11 +411,11 @@
     npy_intp dimensions[3];
     dimensions[0] = height; //numrows
     dimensions[1] = width; //numcols
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if (color_type & PNG_COLOR_MASK_ALPHA)
     {
         dimensions[2] = 4; //RGBA images
     }
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ else if (color_type & PNG_COLOR_MASK_COLOR)
     {
         dimensions[2] = 3; //RGB images
     }
@@ -421,7 +424,7 @@
         dimensions[2] = 1; //Greyscale images
     }
     //For gray, return an x by y array, not an x by y by 1
- int num_dims = (info_ptr->color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;
+ int num_dims = (color_type & PNG_COLOR_MASK_COLOR) ? 3 : 2;

     double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
     PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(

kind regards,
dieter

hi list,

first, thanks for providing matplotlib, i am using it in several projects.

i had problems with several png files and decided to upgrade libpng.
this broke matplotlib.
as you can see in the documentation of libpng15, it is no longer possible
to directly access png_infop.

i have created the following patch:

Dieter,

Thank you, but the modification has already been made to the master branch. I did not consider this as a bug fix, so I applied it only to master, not to the maintenance branch.

Eric

···

On 05/25/2011 10:53 AM, Dieter Schön wrote:

--- matplotlib-1.0.1/src/_png.cpp 2010-10-12 16:14:42.000000000 +0000
+++ matplotlib-1.0.1X/src/_png.cpp 2011-05-25 19:23:36.261752651 +0000
@@ -350,18 +350,21 @@
      png_set_sig_bytes(png_ptr, 8);
      png_read_info(png_ptr, info_ptr);

- png_uint_32 width = info_ptr->width;
- png_uint_32 height = info_ptr->height;
+ png_uint_32 width = png_get_image_width(png_ptr, info_ptr);
+ png_uint_32 height = png_get_image_height(png_ptr, info_ptr);

- int bit_depth = info_ptr->bit_depth;
+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr);

      // Unpack 1, 2, and 4-bit images
      if (bit_depth< 8)
          png_set_packing(png_ptr);

+ // this is needed several times, so safe it in a variable
+ png_byte color_type = png_get_color_type(png_ptr, info_ptr);
+
      // If sig bits are set, shift data
      png_color_8p sig_bit;
- if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)&&
+ if ((color_type != PNG_COLOR_TYPE_PALETTE)&&
          png_get_sBIT(png_ptr, info_ptr,&sig_bit))
      {
          png_set_shift(png_ptr, sig_bit);
@@ -374,13 +377,13 @@
      }

      // Convert palletes to full RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
      {
          png_set_palette_to_rgb(png_ptr);
      }

      // If there's an alpha channel convert gray to RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
      {
          png_set_gray_to_rgb(png_ptr);
      }
@@ -408,11 +411,11 @@
      npy_intp dimensions[3];
      dimensions[0] = height; //numrows
      dimensions[1] = width; //numcols
- if (info_ptr->color_type& PNG_COLOR_MASK_ALPHA)
+ if (color_type& PNG_COLOR_MASK_ALPHA)
      {
          dimensions[2] = 4; //RGBA images
      }
- else if (info_ptr->color_type& PNG_COLOR_MASK_COLOR)
+ else if (color_type& PNG_COLOR_MASK_COLOR)
      {
          dimensions[2] = 3; //RGB images
      }
@@ -421,7 +424,7 @@
          dimensions[2] = 1; //Greyscale images
      }
      //For gray, return an x by y array, not an x by y by 1
- int num_dims = (info_ptr->color_type& PNG_COLOR_MASK_COLOR) ? 3 : 2;
+ int num_dims = (color_type& PNG_COLOR_MASK_COLOR) ? 3 : 2;

      double max_value = (1<< ((bit_depth< 8) ? 8 : bit_depth)) - 1;
      PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(

kind regards,
dieter

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options

   

hi list,

first, thanks for providing matplotlib, i am using it in several projects.

i had problems with several png files and decided to upgrade libpng.
this broke matplotlib.
as you can see in the documentation of libpng15, it is no longer possible
to directly access png_infop.

i have created the following patch:
     

Dieter,

Thank you, but the modification has already been made to the master
branch. I did not consider this as a bug fix, so I applied it only to
master, not to the maintenance branch.
   

It seems to have been applied to the maintenance branch... Maybe someone backported it?

https://github.com/matplotlib/matplotlib/blob/v1.0.x/src/_png.cpp

Mike

···

On 05/25/2011 05:36 PM, Eric Firing wrote:

On 05/25/2011 10:53 AM, Dieter Sch�n wrote:

Eric

--- matplotlib-1.0.1/src/_png.cpp 2010-10-12 16:14:42.000000000 +0000
+++ matplotlib-1.0.1X/src/_png.cpp 2011-05-25 19:23:36.261752651 +0000
@@ -350,18 +350,21 @@
       png_set_sig_bytes(png_ptr, 8);
       png_read_info(png_ptr, info_ptr);

- png_uint_32 width = info_ptr->width;
- png_uint_32 height = info_ptr->height;
+ png_uint_32 width = png_get_image_width(png_ptr, info_ptr);
+ png_uint_32 height = png_get_image_height(png_ptr, info_ptr);

- int bit_depth = info_ptr->bit_depth;
+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr);

       // Unpack 1, 2, and 4-bit images
       if (bit_depth< 8)
           png_set_packing(png_ptr);

+ // this is needed several times, so safe it in a variable
+ png_byte color_type = png_get_color_type(png_ptr, info_ptr);
+
       // If sig bits are set, shift data
       png_color_8p sig_bit;
- if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE)&&
+ if ((color_type != PNG_COLOR_TYPE_PALETTE)&&
           png_get_sBIT(png_ptr, info_ptr,&sig_bit))
       {
           png_set_shift(png_ptr, sig_bit);
@@ -374,13 +377,13 @@
       }

       // Convert palletes to full RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ if (color_type == PNG_COLOR_TYPE_PALETTE)
       {
           png_set_palette_to_rgb(png_ptr);
       }

       // If there's an alpha channel convert gray to RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
+ if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
       {
           png_set_gray_to_rgb(png_ptr);
       }
@@ -408,11 +411,11 @@
       npy_intp dimensions[3];
       dimensions[0] = height; //numrows
       dimensions[1] = width; //numcols
- if (info_ptr->color_type& PNG_COLOR_MASK_ALPHA)
+ if (color_type& PNG_COLOR_MASK_ALPHA)
       {
           dimensions[2] = 4; //RGBA images
       }
- else if (info_ptr->color_type& PNG_COLOR_MASK_COLOR)
+ else if (color_type& PNG_COLOR_MASK_COLOR)
       {
           dimensions[2] = 3; //RGB images
       }
@@ -421,7 +424,7 @@
           dimensions[2] = 1; //Greyscale images
       }
       //For gray, return an x by y array, not an x by y by 1
- int num_dims = (info_ptr->color_type& PNG_COLOR_MASK_COLOR) ? 3 : 2;
+ int num_dims = (color_type& PNG_COLOR_MASK_COLOR) ? 3 : 2;

       double max_value = (1<< ((bit_depth< 8) ? 8 : bit_depth)) - 1;
       PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(

kind regards,
dieter

------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
     
------------------------------------------------------------------------------
vRanger cuts backup time in half-while increasing security.
With the market-leading solution for virtual backup and recovery,
you get blazing-fast, flexible, and affordable data protection.
Download your free trial now.
http://p.sf.net/sfu/quest-d2dcopy1
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
matplotlib-devel List Signup and Options
   
--
Michael Droettboom
Science Software Branch
Space Telescope Science Institute
Baltimore, Maryland, USA

hi list,

first, thanks for providing matplotlib, i am using it in several projects.

i had problems with several png files and decided to upgrade libpng.
this broke matplotlib.
as you can see in the documentation of libpng15, it is no longer possible
to directly access png_infop.

i have created the following patch:

Dieter,

Thank you, but the modification has already been made to the master
branch. I did not consider this as a bug fix, so I applied it only to
master, not to the maintenance branch.

It seems to have been applied to the maintenance branch... Maybe
someone backported it?

Mike,

I think you did--unintentionally! If you look at the graph with qgit (or presumably any other such tool) in the vicinity of your commits on May 6, you will see that this one

a50874b711983cba505ecdb2801c4996eccf3812

made v1.0.x branch off of master; the v1.0.x line was broken by the previous commit. To confirm that this break had the effect of propagating the change in _png.cpp into what is now v1.0.x, you can look at the diff between two commits on "v1.0.x", one of which is a bit before the break, the other after:

git diff 069c21d 0e6dad src/_png.cpp

You will see that the file was changed.

Eric

···

On 05/26/2011 04:40 AM, Michael Droettboom wrote:

On 05/25/2011 05:36 PM, Eric Firing wrote:

On 05/25/2011 10:53 AM, Dieter Schön wrote:

https://github.com/matplotlib/matplotlib/blob/v1.0.x/src/_png.cpp

Mike

I'm still not sure what happened there, and even less sure how to resolve it. Does this mean we have a bunch of other things from master in v1.0.x as well?

Mike

···

On 05/26/2011 03:19 PM, Eric Firing wrote:

Mike,

I think you did--unintentionally! If you look at the graph with qgit
(or presumably any other such tool) in the vicinity of your commits on
May 6, you will see that this one

a50874b711983cba505ecdb2801c4996eccf3812

made v1.0.x branch off of master; the v1.0.x line was broken by the
previous commit. To confirm that this break had the effect of
propagating the change in _png.cpp into what is now v1.0.x, you can look
at the diff between two commits on "v1.0.x", one of which is a bit
before the break, the other after:

git diff 069c21d 0e6dad src/_png.cpp

You will see that the file was changed.

Eric

Mike,

I think you did--unintentionally! If you look at the graph with qgit
(or presumably any other such tool) in the vicinity of your commits on
May 6, you will see that this one

a50874b711983cba505ecdb2801c4996eccf3812

made v1.0.x branch off of master; the v1.0.x line was broken by the
previous commit. To confirm that this break had the effect of
propagating the change in _png.cpp into what is now v1.0.x, you can look
at the diff between two commits on "v1.0.x", one of which is a bit
before the break, the other after:

git diff 069c21d 0e6dad src/_png.cpp

You will see that the file was changed.

Eric

I'm still not sure what happened there, and even less sure how to
resolve it. Does this mean we have a bunch of other things from master
in v1.0.x as well?

Mike,

I wouldn't worry about it. It seems likely that other things from master did leak into v1.0.x, but at this point I don't think it matters. v1.0.x and master both build and run (or did last time I checked). The division between the two is somewhat arbitrary anyway. Tracking down and reversing the leakage, if there is any other than the _png.cpp change (which certainly does no harm in v1.0.x), would not be worthwhile.

Better to just move forward, make improvements, and get some good releases out.

Eric

···

On 05/27/2011 05:02 AM, Michael Droettboom wrote:

On 05/26/2011 03:19 PM, Eric Firing wrote:

Mike