aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2023-09-06 11:44:21 +0200
committerJan200101 <sentrycraft123@gmail.com>2023-09-06 11:44:21 +0200
commit2463d5dfdf1ece466f38b6cd57044dec4caa5b57 (patch)
treefcf98df1f28eac7d0e6dd0347c85be130d4506d0 /src
parent005f8d3797a844c892e53d71cd5ae8855dc4bed6 (diff)
downloadsameboy-thumbnailer-master.tar.gz
sameboy-thumbnailer-master.zip
limit samples to only non zero positive numbersHEADmaster
This fixes a bug with too high scales causing a division by zero
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 6d37dc8..7c9a161 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,8 +58,11 @@ static uint32_t average(const uint32_t dest, const uint32_t src)
}
static void scale_image(const uint32_t* input, const signed input_width, const signed input_height,
- uint32_t* output, const double multiplier, const signed samples)
+ uint32_t* output, const double multiplier, signed samples)
{
+ if (samples <= 0)
+ samples = 1;
+
signed output_width = input_width * multiplier;
uint32_t pixel;