Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ def _draw_unsampled_image(self, renderer, gc):
im.reset_matrix()
numrows, numcols = im.get_size()

if numrows <= 0 or numcols <= 0:
return
im.resize(numcols, numrows) # just to create im.bufOut that
# is required by backends. There
# may be better solution -JJL
Expand Down
6 changes: 3 additions & 3 deletions src/_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)
int numcols = Py::Int(args[0]);
int numrows = Py::Int(args[1]);

if (numcols < 0 || numrows < 0)
if (numcols <= 0 || numrows <= 0)
{
throw Py::RuntimeError(
"Width and height must have non-negative values");
throw Py::RuntimeError(
"Width and height must have positive values");
}

colsOut = numcols;
Expand Down
6 changes: 6 additions & 0 deletions src/_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class Image : public Py::PythonExtension<Image>
inline Py::Object flipud_out(const Py::Tuple& args)
{
args.verify_length(0);
if (colsOut <= 0 || rowsOut <= 0)
{
throw Py::RuntimeError(
"Width and height must have positive values");
}

int stride = rbufOut->stride();
//std::cout << "flip before: " << rbufOut->stride() << std::endl;
rbufOut->attach(bufferOut, colsOut, rowsOut, -stride);
Expand Down