diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-11-07 16:38:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-07 16:38:09 +0100 |
commit | 329d2c1ced685a107b1c27e67b212b5620968a0a (patch) | |
tree | a737d8af45d01138c8b21ccb20c230614deade35 /core/image.cpp | |
parent | df6fa6c306409b28385e40c945fe7d5f201a3fd2 (diff) | |
parent | 0209e3790e4ab984b811f2994947ae71eef69b82 (diff) |
Merge pull request #42947 from Calinou/image-load-bmp-from-buffer
Add `Image.load_bmp_from_buffer()` for run-time BMP image loading
Diffstat (limited to 'core/image.cpp')
-rw-r--r-- | core/image.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/core/image.cpp b/core/image.cpp index b8a443eed2..950ff9b48d 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -2711,6 +2711,7 @@ ImageMemLoadFunc Image::_png_mem_loader_func = nullptr; ImageMemLoadFunc Image::_jpg_mem_loader_func = nullptr; ImageMemLoadFunc Image::_webp_mem_loader_func = nullptr; ImageMemLoadFunc Image::_tga_mem_loader_func = nullptr; +ImageMemLoadFunc Image::_bmp_mem_loader_func = nullptr; void (*Image::_image_compress_bc_func)(Image *, float, Image::UsedChannels) = nullptr; void (*Image::_image_compress_bptc_func)(Image *, float, Image::UsedChannels) = nullptr; @@ -3141,6 +3142,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("load_jpg_from_buffer", "buffer"), &Image::load_jpg_from_buffer); ClassDB::bind_method(D_METHOD("load_webp_from_buffer", "buffer"), &Image::load_webp_from_buffer); ClassDB::bind_method(D_METHOD("load_tga_from_buffer", "buffer"), &Image::load_tga_from_buffer); + ClassDB::bind_method(D_METHOD("load_bmp_from_buffer", "buffer"), &Image::load_bmp_from_buffer); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data"); @@ -3473,10 +3475,21 @@ Error Image::load_webp_from_buffer(const Vector<uint8_t> &p_array) { } Error Image::load_tga_from_buffer(const Vector<uint8_t> &p_array) { - ERR_FAIL_NULL_V_MSG(_tga_mem_loader_func, ERR_UNAVAILABLE, "TGA module was not installed."); + ERR_FAIL_NULL_V_MSG( + _tga_mem_loader_func, + ERR_UNAVAILABLE, + "The TGA module isn't enabled. Recompile the Godot editor or export template binary with the `module_tga_enabled=yes` SCons option."); return _load_from_buffer(p_array, _tga_mem_loader_func); } +Error Image::load_bmp_from_buffer(const Vector<uint8_t> &p_array) { + ERR_FAIL_NULL_V_MSG( + _bmp_mem_loader_func, + ERR_UNAVAILABLE, + "The BMP module isn't enabled. Recompile the Godot editor or export template binary with the `module_bmp_enabled=yes` SCons option."); + return _load_from_buffer(p_array, _bmp_mem_loader_func); +} + void Image::convert_rg_to_ra_rgba8() { ERR_FAIL_COND(format != FORMAT_RGBA8); ERR_FAIL_COND(!data.size()); |