diff --git a/src/_backend_agg.cpp b/src/_backend_agg.cpp index b088c97c9aa3..6473526b16eb 100644 --- a/src/_backend_agg.cpp +++ b/src/_backend_agg.cpp @@ -2518,9 +2518,11 @@ Py::Object _backend_agg_module::new_renderer(const Py::Tuple &args, unsigned int height = (int)Py::Int(args[1]); double dpi = Py::Float(args[2]); - if (width > 1 << 15 || height > 1 << 15) + char msg [256]; + if (width > INT_MAX || height > INT_MAX) { - throw Py::ValueError("width and height must each be below 32768"); + sprintf(msg, "width and height must each be below %d", INT_MAX); + throw Py::ValueError(msg); } if (dpi <= 0.0) diff --git a/src/_backend_agg.h b/src/_backend_agg.h index 100ac4819f73..ad302e329e3a 100644 --- a/src/_backend_agg.h +++ b/src/_backend_agg.h @@ -7,6 +7,7 @@ #ifndef __BACKEND_AGG_H #define __BACKEND_AGG_H #include +#include #include "CXX/Extensions.hxx" #include "agg_arrowhead.h" @@ -59,10 +60,15 @@ typedef agg::renderer_scanline_aa_solid renderer_aa; typedef agg::renderer_scanline_bin_solid renderer_bin; typedef agg::rasterizer_scanline_aa rasterizer; -typedef agg::scanline_p8 scanline_p8; -typedef agg::scanline_bin scanline_bin; +// typedef agg::scanline_p8 scanline_p8; // 16 bits display rendering +// typedef agg::scanline_bin scanline_bin; // 16 bits display rendering +typedef agg::scanline32_p8 scanline_p8; // 32 bits display rendering +typedef agg::scanline32_bin scanline_bin; // 32 bits display rendering + typedef agg::amask_no_clip_gray8 alpha_mask_type; -typedef agg::scanline_u8_am scanline_am; + +// typedef agg::scanline_u8_am scanline_am; // 16 bits display rendering +typedef agg::scanline32_u8_am scanline_am; // 32 bits display rendering typedef agg::renderer_base renderer_base_alpha_mask_type; typedef agg::renderer_scanline_aa_solid renderer_alpha_mask_type; diff --git a/src/_image.cpp b/src/_image.cpp index 73f2624c772c..700e3ca56591 100644 --- a/src/_image.cpp +++ b/src/_image.cpp @@ -786,9 +786,11 @@ _image_module::from_images(const Py::Tuple& args) size_t numrows = (long)Py::Int(args[0]); size_t numcols = (long)Py::Int(args[1]); - if (numrows >= 32768 || numcols >= 32768) + char msg [256]; + if (numrows >= INT_MAX || numcols >= INT_MAX) { - throw Py::RuntimeError("numrows and numcols must both be less than 32768"); + sprintf(msg, "numrows and numcols must both be less than %d", INT_MAX); + throw Py::ValueError(msg); } Py::SeqBase tups = args[2]; @@ -1268,9 +1270,11 @@ _image_module::frombuffer(const Py::Tuple& args) size_t x = (long)Py::Int(args[1]); size_t y = (long)Py::Int(args[2]); - if (x >= 32768 || y >= 32768) + char msg [256]; + if (x >= INT_MAX || y >= INT_MAX) { - throw Py::ValueError("x and y must both be less than 32768"); + sprintf(msg, "numrows and numcols must both be less than %d", INT_MAX); + throw Py::ValueError(msg); } int isoutput = Py::Int(args[3]); @@ -1576,9 +1580,11 @@ _image_module::pcolor(const Py::Tuple& args) Py::Tuple bounds = args[5]; unsigned int interpolation = (unsigned long)Py::Int(args[6]); - if (rows >= 32768 || cols >= 32768) + char msg [256]; + if (rows >= INT_MAX || cols >= INT_MAX) { - throw Py::ValueError("rows and cols must both be less than 32768"); + sprintf(msg, "rows and cols must both be less than %d", INT_MAX); + throw Py::ValueError(msg); } if (bounds.length() != 4) @@ -1822,11 +1828,15 @@ _image_module::pcolor2(const Py::Tuple& args) Py::Tuple bounds = args[5]; Py::Object bgp = args[6]; - if (rows >= 32768 || cols >= 32768) + char msg [256]; + if (rows >= INT_MAX || cols >= INT_MAX) { - throw Py::ValueError("rows and cols must both be less than 32768"); + sprintf(msg, "rows and cols must both be less than %d", INT_MAX); + throw Py::ValueError(msg); } + + if (bounds.length() != 4) { throw Py::TypeError("Incorrect number of bounds (4 expected)"); diff --git a/src/_image.h b/src/_image.h index aa0de94174cd..cf7af5385aa6 100644 --- a/src/_image.h +++ b/src/_image.h @@ -7,6 +7,7 @@ #ifndef _IMAGE_H #define _IMAGE_H #include +#include #include "Python.h" #include "agg_trans_affine.h" diff --git a/src/cntr.c b/src/cntr.c index 4448714b6a59..1781b2f99419 100644 --- a/src/cntr.c +++ b/src/cntr.c @@ -183,7 +183,8 @@ /* the data about edges, zones, and points -- boundary or not, exists * or not, z value 0, 1, or 2 -- is kept in a mesh sized data array */ -typedef short Cdata; +// typedef short Cdata; // 16 bits display rendering +typedef int Cdata; // 32 bits display rendering /* information to decide on correct contour direction in saddle zones * is stored in a mesh sized array. Only those entries corresponding