diff options
author | BlueCube3310 <53150244+BlueCube3310@users.noreply.github.com> | 2024-02-24 12:41:08 +0100 |
---|---|---|
committer | BlueCube3310 <53150244+BlueCube3310@users.noreply.github.com> | 2024-02-28 19:42:06 +0100 |
commit | 8239aeec8ede9c6fadec56e842665c392a835a0a (patch) | |
tree | ad43a9a5ba025bc422590a794e4653ebf2093989 /core/io/image.cpp | |
parent | 2e7fc81315bfa8d0a15f60adff2a12b6f3104236 (diff) | |
download | redot-engine-8239aeec8ede9c6fadec56e842665c392a835a0a.tar.gz |
Image: Add static `is_format_compressed` function.
Diffstat (limited to 'core/io/image.cpp')
-rw-r--r-- | core/io/image.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp index b094290ac8..ad471720b2 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -521,7 +521,7 @@ void Image::convert(Format p_new_format) { // Includes the main image. const int mipmap_count = get_mipmap_count() + 1; - if (format > FORMAT_RGBE9995 || p_new_format > FORMAT_RGBE9995) { + if (Image::is_format_compressed(format) || Image::is_format_compressed(p_new_format)) { ERR_FAIL_MSG("Cannot convert to <-> from compressed formats. Use compress() and decompress() instead."); } else if (format > FORMAT_RGBA8 || p_new_format > FORMAT_RGBA8) { @@ -1662,7 +1662,7 @@ int Image::_get_dst_image_size(int p_width, int p_height, Format p_format, int & } bool Image::_can_modify(Format p_format) const { - return p_format <= FORMAT_RGBE9995; + return !Image::is_format_compressed(p_format); } template <class Component, int CC, bool renormalize, @@ -2616,7 +2616,11 @@ int Image::get_image_mipmap_offset_and_dimensions(int p_width, int p_height, For } bool Image::is_compressed() const { - return format > FORMAT_RGBE9995; + return is_format_compressed(format); +} + +bool Image::is_format_compressed(Format p_format) { + return p_format > FORMAT_RGBE9995; } Error Image::decompress() { |