summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHugues Ross <hugues.ross@gmail.com>2020-06-01 09:22:04 -0400
committerGitHub <noreply@github.com>2020-06-01 15:22:04 +0200
commitf849917bbe9c5eff51bee0a3125eabed16efb172 (patch)
treea10ec2ee0bd5e50f128e88001dbab1c7ffb17051 /src
parent51de4ae297c3dc3380bf5d12288afc75f6de2f30 (diff)
downloadminetest-f849917bbe9c5eff51bee0a3125eabed16efb172.tar.gz
minetest-f849917bbe9c5eff51bee0a3125eabed16efb172.tar.bz2
minetest-f849917bbe9c5eff51bee0a3125eabed16efb172.zip
imageScaleNNAA: Fix image clipping on rect- instead of image dimensions (#9896)
Fixes GUI scaling filters applied on animated images and 9slice backgrounds.
Diffstat (limited to 'src')
-rw-r--r--src/client/imagefilters.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/client/imagefilters.cpp b/src/client/imagefilters.cpp
index dd029628f..0fa501410 100644
--- a/src/client/imagefilters.cpp
+++ b/src/client/imagefilters.cpp
@@ -91,7 +91,7 @@ void imageScaleNNAA(video::IImage *src, const core::rect<s32> &srcrect, video::I
u32 dy, dx;
video::SColor pxl;
- // Cache rectsngle boundaries.
+ // Cache rectangle boundaries.
double sox = srcrect.UpperLeftCorner.X * 1.0;
double soy = srcrect.UpperLeftCorner.Y * 1.0;
double sw = srcrect.getWidth() * 1.0;
@@ -107,15 +107,15 @@ void imageScaleNNAA(video::IImage *src, const core::rect<s32> &srcrect, video::I
// Do some basic clipping, and for mirrored/flipped rects,
// make sure min/max are in the right order.
minsx = sox + (dx * sw / dim.Width);
- minsx = rangelim(minsx, 0, sw);
+ minsx = rangelim(minsx, 0, sox + sw);
maxsx = minsx + sw / dim.Width;
- maxsx = rangelim(maxsx, 0, sw);
+ maxsx = rangelim(maxsx, 0, sox + sw);
if (minsx > maxsx)
SWAP(double, minsx, maxsx);
minsy = soy + (dy * sh / dim.Height);
- minsy = rangelim(minsy, 0, sh);
+ minsy = rangelim(minsy, 0, soy + sh);
maxsy = minsy + sh / dim.Height;
- maxsy = rangelim(maxsy, 0, sh);
+ maxsy = rangelim(maxsy, 0, soy + sh);
if (minsy > maxsy)
SWAP(double, minsy, maxsy);