Created
April 3, 2012 18:01
-
-
Save belevtsoff/2294220 to your computer and use it in GitHub Desktop.
matplotlib 1.0.1 patches for libpng>=1.5 and python 2.7.2's tk support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- matplotlib-1.0.1/src/_png.cpp 2010-10-12 19:14:42.000000000 +0300 | |
+++ matplotlib-1.0.1.patched/src/_png.cpp 2012-04-03 20:27:10.310604265 +0300 | |
@@ -1,3 +1,4 @@ | |
+/* -*- mode: c++; c-basic-offset: 4 -*- */ | |
/* For linux, png.h must be imported before Python.h because | |
png.h needs to be the one to define setjmp. | |
@@ -350,10 +351,10 @@ | |
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 +362,7 @@ | |
// 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 +375,13 @@ | |
} | |
// 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 +409,11 @@ | |
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 +422,8 @@ | |
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( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- matplotlib-1.0.1/setupext.py 2010-07-07 04:41:55.000000000 +0300 | |
+++ matplotlib-1.0.1.patched/setupext.py 2012-04-03 20:26:58.880603940 +0300 | |
@@ -828,8 +828,13 @@ | |
gotit = False | |
if gotit: | |
+ try: | |
+ tk_v = Tkinter.__version__.split()[-2] | |
+ except IndexError: | |
+ tk_v = 'version not identified' | |
print_status("Tkinter", "Tkinter: %s, Tk: %s, Tcl: %s" % | |
- (Tkinter.__version__.split()[-2], Tkinter.TkVersion, Tkinter.TclVersion)) | |
+ (tk_v, Tkinter.TkVersion, Tkinter.TclVersion)) | |
+ | |
else: | |
print_status("Tkinter", "no") | |
if explanation is not None: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment