Skip to content

Commit

Permalink
Fix bug introduced in code cleanup commit 5e0c305
Browse files Browse the repository at this point in the history
The previous cleanup didn't handle the case when w or h is zero,
but resize_mode is not stretch.
  • Loading branch information
fluffbeast authored and GregoryLundberg committed Jan 29, 2018
1 parent d82fc9c commit 16c3fda
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/gui/core/canvas.cpp
Expand Up @@ -1109,27 +1109,28 @@ void image_shape::draw(surface& canvas,
surf = image_;
}
else { // assert((w != 0) || (h != 0))
if(w == 0) { // assert(h != 0)
if(resize_mode_ == stretch) {
DBG_GUI_D << "Image: vertical stretch from " << image_->w << ','
<< image_->h << " to a height of " << h << ".\n";
if(w == 0 && resize_mode_ == stretch) {
DBG_GUI_D << "Image: vertical stretch from " << image_->w << ','
<< image_->h << " to a height of " << h << ".\n";

surf = stretch_surface_vertical(image_, h);
}
surf = stretch_surface_vertical(image_, h);
w = image_->w;
}
else if(h == 0) { // assert(w != 0)
if(resize_mode_ == stretch) {
DBG_GUI_D << "Image: horizontal stretch from " << image_->w
<< ',' << image_->h << " to a width of " << w
<< ".\n";
else if(h == 0 && resize_mode_ == stretch) {
DBG_GUI_D << "Image: horizontal stretch from " << image_->w
<< ',' << image_->h << " to a width of " << w
<< ".\n";

surf = stretch_surface_horizontal(image_, w);
}
surf = stretch_surface_horizontal(image_, w);
h = image_->h;
}
else { // assert((w != 0) && (h != 0))

else {
if(w == 0) {
w = image_->w;
}
if(h == 0) {
h = image_->h;
}
if(resize_mode_ == tile) {
DBG_GUI_D << "Image: tiling from " << image_->w << ','
<< image_->h << " to " << w << ',' << h << ".\n";
Expand Down

0 comments on commit 16c3fda

Please sign in to comment.