python-matplotlib/use-png-accessor-functions.patch
2011-12-06 16:55:19 -05:00

80 lines
3.4 KiB
Diff

diff -up matplotlib-1.0.1/CHANGELOG.png15 matplotlib-1.0.1/CHANGELOG
diff -up matplotlib-1.0.1/doc/users/installing.rst.png15 matplotlib-1.0.1/doc/users/installing.rst
--- matplotlib-1.0.1/doc/users/installing.rst.png15 2010-07-06 21:41:46.000000000 -0400
+++ matplotlib-1.0.1/doc/users/installing.rst 2011-12-06 16:29:05.824621532 -0500
@@ -138,7 +138,7 @@ libraries themselves.
array support for python (`download
<http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__)
-libpng 1.1 (or later)
+libpng 1.2 (or later)
library for loading and saving :term:`PNG` files (`download
<http://www.libpng.org/pub/png/libpng.html>`__). libpng requires
zlib. If you are a windows user, you can ignore this since we
diff -up matplotlib-1.0.1/src/_png.cpp.png15 matplotlib-1.0.1/src/_png.cpp
--- matplotlib-1.0.1/src/_png.cpp.png15 2010-10-12 12:14:42.000000000 -0400
+++ matplotlib-1.0.1/src/_png.cpp 2011-12-06 16:29:05.825621532 -0500
@@ -350,10 +350,10 @@ _png_module::read_png(const Py::Tuple& a
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)
@@ -361,7 +361,7 @@ _png_module::read_png(const Py::Tuple& a
// If sig bits are set, shift data
png_color_8p sig_bit;
- if ((info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) &&
+ if ((png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_PALETTE) &&
png_get_sBIT(png_ptr, info_ptr, &sig_bit))
{
png_set_shift(png_ptr, sig_bit);
@@ -374,13 +374,13 @@ _png_module::read_png(const Py::Tuple& a
}
// Convert palletes to full RGB
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+ if (png_get_color_type(png_ptr, info_ptr) == 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 (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA)
{
png_set_gray_to_rgb(png_ptr);
}
@@ -408,11 +408,11 @@ _png_module::read_png(const Py::Tuple& a
npy_intp dimensions[3];
dimensions[0] = height; //numrows
dimensions[1] = width; //numcols
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
+ if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_ALPHA)
{
dimensions[2] = 4; //RGBA images
}
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+ else if (png_get_color_type(png_ptr, info_ptr) & PNG_COLOR_MASK_COLOR)
{
dimensions[2] = 3; //RGB images
}
@@ -421,7 +421,8 @@ _png_module::read_png(const Py::Tuple& a
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 = (png_get_color_type(png_ptr, info_ptr)
+ & PNG_COLOR_MASK_COLOR) ? 3 : 2;
double max_value = (1 << ((bit_depth < 8) ? 8 : bit_depth)) - 1;
PyArrayObject *A = (PyArrayObject *) PyArray_SimpleNew(