FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Image: handle images with zero columns or rows. by efiring · Pull Request #3102 · matplotlib/matplotlib · GitHub

Repository navigation

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

Filter by extension

Filter by extension .cpp  (1) .h  (1) .py  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 2 additions & 0 deletions lib/matplotlib/image.py
This file contains hidden or 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
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
This file contains hidden or 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
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
This file contains hidden or 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
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

Back | FazBrowse Home | New Git URL