From 685705f8259b7e2b21522d5b4d01e7e75e20b8e7 Mon Sep 17 00:00:00 2001 From: Sertonix Date: Fri, 2 Aug 2024 15:42:11 +0200 Subject: svg: honor --stretch option --- svg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'svg.c') diff --git a/svg.c b/svg.c index b9d5d6e..a62793f 100644 --- a/svg.c +++ b/svg.c @@ -1,4 +1,5 @@ #include "svg.h" +#include #include #include @@ -31,7 +32,7 @@ svg_load(FILE *fp, const char *path) } pixman_image_t * -svg_render(const int width, const int height) +svg_render(const int width, const int height, bool stretch) { pixman_image_t *pix = NULL; uint8_t *data = NULL; @@ -42,8 +43,7 @@ svg_render(const int width, const int height) double sx = width / (double)svg_image->width; double sy = height / (double)svg_image->height; - - float s = sx > sy ? sy : sx; + double s = stretch ? fmax(sx, sy) : fmin(sx, sy); float tx = (width - svg_image->width * s) / 2; float ty = (height - svg_image->height * s) / 2; -- cgit v1.2.3