From 1470eb6fa4166d41163d137bdfd5c19b7d60e312 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Mon, 30 Jan 2023 16:06:18 +0100 Subject: [PATCH] gg: fix native image rendering with with/height=0 --- vlib/gg/image.c.v | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/vlib/gg/image.c.v b/vlib/gg/image.c.v index f5f421766..f7496b5e9 100644 --- a/vlib/gg/image.c.v +++ b/vlib/gg/image.c.v @@ -283,8 +283,18 @@ pub fn (ctx &Context) draw_image_with_config(config DrawImageConfig) { } x := config.img_rect.x y := config.img_rect.y - C.darwin_draw_image(x, ctx.height - (y + config.img_rect.height), config.img_rect.width, - config.img_rect.height, img) + width := if config.img_rect.width == 0 { + f32(img.width) + } else { + config.img_rect.width + } + height := if config.img_rect.height == 0 { + f32(img.height) + } else { + config.img_rect.height + } + C.darwin_draw_image(x, ctx.height - (y + config.img_rect.height), width, + height, img) return } } -- 2.30.2