From c07cd406cbe3a80869c657b1b0ce22088954cccb Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Sun, 12 Nov 2023 00:04:16 +0800 Subject: Fix crash when saving compressed image as JPG & WebP --- modules/webp/webp_common.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/webp/webp_common.cpp') diff --git a/modules/webp/webp_common.cpp b/modules/webp/webp_common.cpp index bc34a25733..3a2ac5a90e 100644 --- a/modules/webp/webp_common.cpp +++ b/modules/webp/webp_common.cpp @@ -59,6 +59,10 @@ Vector _webp_packer(const Ref &p_image, float p_quality, bool p_ compression_method = CLAMP(compression_method, 0, 6); Ref img = p_image->duplicate(); + if (img->is_compressed()) { + Error error = img->decompress(); + ERR_FAIL_COND_V_MSG(error != OK, Vector(), "Couldn't decompress image."); + } if (img->detect_alpha()) { img->convert(Image::FORMAT_RGBA8); } else { -- cgit v1.2.3