summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/jpg/image_loader_jpegd.cpp6
-rw-r--r--modules/webp/webp_common.cpp4
2 files changed, 9 insertions, 1 deletions
diff --git a/modules/jpg/image_loader_jpegd.cpp b/modules/jpg/image_loader_jpegd.cpp
index 0b9fcf4455..e7fa909706 100644
--- a/modules/jpg/image_loader_jpegd.cpp
+++ b/modules/jpg/image_loader_jpegd.cpp
@@ -156,7 +156,11 @@ public:
static Error _jpgd_save_to_output_stream(jpge::output_stream *p_output_stream, const Ref<Image> &p_img, float p_quality) {
ERR_FAIL_COND_V(p_img.is_null() || p_img->is_empty(), ERR_INVALID_PARAMETER);
- Ref<Image> image = p_img;
+ Ref<Image> image = p_img->duplicate();
+ if (image->is_compressed()) {
+ Error error = image->decompress();
+ ERR_FAIL_COND_V_MSG(error != OK, error, "Couldn't decompress image.");
+ }
if (image->get_format() != Image::FORMAT_RGB8) {
image->convert(Image::FORMAT_RGB8);
}
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<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 {