1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-10 13:00:37 +00:00

Fix crash when saving compressed image as JPG & WebP

This commit is contained in:
Haoyu Qiu
2023-11-12 00:04:16 +08:00
parent e38686f85b
commit c07cd406cb
2 changed files with 9 additions and 1 deletions

View File

@@ -59,6 +59,10 @@ Vector<uint8_t> _webp_packer(const Ref<Image> &p_image, float p_quality, bool p_
compression_method = CLAMP(compression_method, 0, 6);
Ref<Image> img = p_image->duplicate();
if (img->is_compressed()) {
Error error = img->decompress();
ERR_FAIL_COND_V_MSG(error != OK, Vector<uint8_t>(), "Couldn't decompress image.");
}
if (img->detect_alpha()) {
img->convert(Image::FORMAT_RGBA8);
} else {