From e8fc6bfeb53801447de25c12ba7536f574d121f4 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 8 Jul 2022 15:01:02 +0200 Subject: [Core] Make ImageFormatLoader extensible. --- modules/bmp/image_loader_bmp.cpp | 2 +- modules/bmp/image_loader_bmp.h | 2 +- modules/bmp/register_types.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'modules/bmp') diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index ae03abca50..cc21ed28e8 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -200,7 +200,7 @@ Error ImageLoaderBMP::convert_to_image(Ref p_image, return err; } -Error ImageLoaderBMP::load_image(Ref p_image, Ref f, uint32_t p_flags, float p_scale) { +Error ImageLoaderBMP::load_image(Ref p_image, Ref f, BitField p_flags, float p_scale) { bmp_header_s bmp_header; Error err = ERR_INVALID_DATA; diff --git a/modules/bmp/image_loader_bmp.h b/modules/bmp/image_loader_bmp.h index cf8346ecad..0ca54de1dc 100644 --- a/modules/bmp/image_loader_bmp.h +++ b/modules/bmp/image_loader_bmp.h @@ -83,7 +83,7 @@ protected: const bmp_header_s &p_header); public: - virtual Error load_image(Ref p_image, Ref f, uint32_t p_flags, float p_scale); + virtual Error load_image(Ref p_image, Ref f, BitField p_flags, float p_scale); virtual void get_recognized_extensions(List *p_extensions) const; ImageLoaderBMP(); }; diff --git a/modules/bmp/register_types.cpp b/modules/bmp/register_types.cpp index 7c4a2085b2..67858e9d46 100644 --- a/modules/bmp/register_types.cpp +++ b/modules/bmp/register_types.cpp @@ -32,14 +32,14 @@ #include "image_loader_bmp.h" -static ImageLoaderBMP *image_loader_bmp = nullptr; +static Ref image_loader_bmp; void initialize_bmp_module(ModuleInitializationLevel p_level) { if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) { return; } - image_loader_bmp = memnew(ImageLoaderBMP); + image_loader_bmp.instantiate(); ImageLoader::add_image_format_loader(image_loader_bmp); } @@ -48,5 +48,6 @@ void uninitialize_bmp_module(ModuleInitializationLevel p_level) { return; } - memdelete(image_loader_bmp); + ImageLoader::remove_image_format_loader(image_loader_bmp); + image_loader_bmp.unref(); } -- cgit v1.2.3