diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2022-08-25 16:51:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-25 16:51:26 +0200 |
commit | 0cf0e960387620e6a206b5417b25aca008788043 (patch) | |
tree | 26e9fe00f0ff3ae580c58aeb3f95d2fbf45642be /core/io | |
parent | cfcdd576dd14fa98bc8404f4091f2f54eece3d87 (diff) | |
parent | 672e9d6868dd422f87fdbf69e6b7f0ecd84c4b64 (diff) |
Merge pull request #64776 from YuriSizov/import-images-moar-flags
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/image_loader.cpp | 6 | ||||
-rw-r--r-- | core/io/image_loader.h | 9 |
2 files changed, 10 insertions, 5 deletions
diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 9cf7c9caba..d09697b951 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -44,7 +44,7 @@ bool ImageFormatLoader::recognize(const String &p_extension) const { return false; } -Error ImageLoader::load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom, bool p_force_linear, float p_scale) { +Error ImageLoader::load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom, uint32_t p_flags, float p_scale) { ERR_FAIL_COND_V_MSG(p_image.is_null(), ERR_INVALID_PARAMETER, "It's not a reference to a valid Image object."); Ref<FileAccess> f = p_custom; @@ -60,7 +60,7 @@ Error ImageLoader::load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> if (!loader[i]->recognize(extension)) { continue; } - Error err = loader[i]->load_image(p_image, f, p_force_linear, p_scale); + Error err = loader[i]->load_image(p_image, f, p_flags, p_scale); if (err != OK) { ERR_PRINT("Error loading image: " + p_file); } @@ -152,7 +152,7 @@ Ref<Resource> ResourceFormatLoaderImage::load(const String &p_path, const String Ref<Image> image; image.instantiate(); - Error err = ImageLoader::loader[idx]->load_image(image, f, false, 1.0); + Error err = ImageLoader::loader[idx]->load_image(image, f); if (err != OK) { if (r_error) { diff --git a/core/io/image_loader.h b/core/io/image_loader.h index c91d382c25..cb64d2310e 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -44,11 +44,16 @@ class ImageFormatLoader { friend class ResourceFormatLoaderImage; protected: - virtual Error load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, bool p_force_linear, float p_scale) = 0; + virtual Error load_image(Ref<Image> p_image, Ref<FileAccess> p_fileaccess, uint32_t p_flags = (uint32_t)FLAG_NONE, float p_scale = 1.0) = 0; virtual void get_recognized_extensions(List<String> *p_extensions) const = 0; bool recognize(const String &p_extension) const; public: + enum LoaderFlags { + FLAG_NONE = 0, + FLAG_FORCE_LINEAR = 1, + }; + virtual ~ImageFormatLoader() {} }; @@ -58,7 +63,7 @@ class ImageLoader { protected: public: - static Error load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom = Ref<FileAccess>(), bool p_force_linear = false, float p_scale = 1.0); + static Error load_image(String p_file, Ref<Image> p_image, Ref<FileAccess> p_custom = Ref<FileAccess>(), uint32_t p_flags = (uint32_t)ImageFormatLoader::FLAG_NONE, float p_scale = 1.0); static void get_recognized_extensions(List<String> *p_extensions); static ImageFormatLoader *recognize(const String &p_extension); |