commit 3ea0875

sewn  ·  2026-05-10 09:42:13 +0000 UTC
parent df7339c
make the fit/fill make sense
1 files changed,  +4, -4
M wawa.c
M wawa.c
+4, -4
 1@@ -118,7 +118,7 @@ image_fit(unsigned char *dst, struct output *output)
 2 	crop.y = (output->height - crop.height) / 2;
 3 	stbir_resize_uint8_linear(
 4 	  image.data, image.width, image.height, image.width * 4,
 5-		dst + (crop.y * output->stride) + (crop.x * 4),
 6+		dst + crop.y * output->stride + crop.x * 4,
 7 		crop.width, crop.height, output->stride, 4);
 8 }
 9 
10@@ -131,10 +131,10 @@ image_fill(unsigned char *dst, struct output *output)
11 	factor = fmin((double)image.width/output->width, (double)image.height/output->height);
12 	crop.width = output->width * factor;
13 	crop.height = output->height * factor;
14-	crop.x = (image.width - (crop.width)) / 2;
15-	crop.y = (image.height - (crop.height)) / 2;
16+	crop.x = (image.width - crop.width) / 2;
17+	crop.y = (image.height - crop.height) / 2;
18 	stbir_resize_uint8_linear(
19-	  image.data + (crop.y * image.width + crop.x) * 4,
20+	  image.data + crop.y * image.width * 4 + crop.x * 4,
21 	  crop.width, crop.height, image.width * 4,
22 		dst, output->width, output->height, output->stride, 4);
23 }