8c18b08ac5
All fixes from/via NetBSD pkgsrc. The people there did a lot of heavy lifting.
69 lines
2.8 KiB
Plaintext
69 lines
2.8 KiB
Plaintext
$OpenBSD: patch-src__png_cpp,v 1.1 2011/07/08 20:36:09 naddy Exp $
|
|
|
|
Fix build with png-1.5.
|
|
|
|
--- src/_png.cpp.orig Tue Jul 5 21:43:21 2011
|
|
+++ src/_png.cpp Tue Jul 5 21:47:50 2011
|
|
@@ -122,7 +122,7 @@ Py::Object _png_module::write_png(const Py::Tuple& arg
|
|
throw Py::RuntimeError("Could not create info struct");
|
|
}
|
|
|
|
- if (setjmp(png_ptr->jmpbuf)) {
|
|
+ if (setjmp(png_jmpbuf(png_ptr))) {
|
|
throw Py::RuntimeError("Error building image");
|
|
}
|
|
|
|
@@ -211,12 +211,12 @@ _png_module::read_png(const Py::Tuple& args) {
|
|
|
|
png_read_info(png_ptr, info_ptr);
|
|
|
|
- png_uint_32 width = info_ptr->width;
|
|
- png_uint_32 height = info_ptr->height;
|
|
- bool do_gray_conversion = (info_ptr->bit_depth < 8 &&
|
|
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY);
|
|
+ png_uint_32 width = png_get_image_width(png_ptr, info_ptr);
|
|
+ png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
|
+ bool do_gray_conversion = (png_get_bit_depth(png_ptr, info_ptr) < 8 &&
|
|
+ png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY);
|
|
|
|
- int bit_depth = info_ptr->bit_depth;
|
|
+ int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
|
if (bit_depth == 16) {
|
|
png_set_strip_16(png_ptr);
|
|
} else if (bit_depth < 8) {
|
|
@@ -224,19 +224,19 @@ _png_module::read_png(const Py::Tuple& args) {
|
|
}
|
|
|
|
// convert misc color types to rgb for simplicity
|
|
- if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY ||
|
|
- info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
|
+ if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY ||
|
|
+ png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_GRAY_ALPHA) {
|
|
png_set_gray_to_rgb(png_ptr);
|
|
- } else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) {
|
|
+ } else if (png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_PALETTE) {
|
|
png_set_palette_to_rgb(png_ptr);
|
|
}
|
|
|
|
png_set_interlace_handling(png_ptr);
|
|
png_read_update_info(png_ptr, info_ptr);
|
|
|
|
- bool rgba = info_ptr->color_type == PNG_COLOR_TYPE_RGBA;
|
|
- if ( (info_ptr->color_type != PNG_COLOR_TYPE_RGB) && !rgba) {
|
|
- std::cerr << "Found color type " << (int)info_ptr->color_type << std::endl;
|
|
+ bool rgba = png_get_color_type(png_ptr, info_ptr) == PNG_COLOR_TYPE_RGBA;
|
|
+ if ( (png_get_color_type(png_ptr, info_ptr) != PNG_COLOR_TYPE_RGB) && !rgba) {
|
|
+ std::cerr << "Found color type " << (int)png_get_color_type(png_ptr, info_ptr) << std::endl;
|
|
throw Py::RuntimeError("_image_module::readpng: cannot handle color_type");
|
|
}
|
|
|
|
@@ -288,7 +288,7 @@ _png_module::read_png(const Py::Tuple& args) {
|
|
|
|
//free the png memory
|
|
png_read_end(png_ptr, info_ptr);
|
|
- png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
|
|
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
|
fclose(fp);
|
|
for (row = 0; row < height; row++)
|
|
delete [] row_pointers[row];
|