Skip to content

Commit

Permalink
Prevent crash when decompressing image with mipmaps
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitalita committed Nov 6, 2024
1 parent 7cd4a8c commit d63c474
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions exporters/texture_exporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ Error TextureExporter::_convert_bitmap(const String &p_path, const String &dest_
Error TextureExporter::save_image(const String &dest_path, const Ref<Image> &img, bool lossy) {
String dest_ext = dest_path.get_extension().to_lower();
Error err = OK;
if (img->is_compressed() && img->has_mipmaps()) {
img->clear_mipmaps();
}
GDRE_ERR_DECOMPRESS_OR_FAIL(img);
if (dest_ext == "jpg" || dest_ext == "jpeg") {
err = gdre::save_image_as_jpeg(dest_path, img);
Expand Down Expand Up @@ -154,6 +157,10 @@ Error TextureExporter::_convert_atex(const String &p_path, const String &dest_pa
image_format = Image::get_format_name(img->get_format());

img = img->duplicate();
if (img->is_compressed() && img->has_mipmaps()) {
img->clear_mipmaps();
}

// resize it according to the properties of the atlas
GDRE_ERR_DECOMPRESS_OR_FAIL(img);
if (img->get_format() != Image::FORMAT_RGBA8) {
Expand Down

0 comments on commit d63c474

Please sign in to comment.