Add Image.load_exr_from_buffer and enable tinyexr by default

This commit is contained in:
metamuffin 2025-01-08 00:40:08 +01:00
parent b79fe2e020
commit 6145b0ca29
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654
8 changed files with 52 additions and 4 deletions

View file

@ -3925,6 +3925,7 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("load_bmp_from_buffer", "buffer"), &Image::load_bmp_from_buffer);
ClassDB::bind_method(D_METHOD("load_ktx_from_buffer", "buffer"), &Image::load_ktx_from_buffer);
ClassDB::bind_method(D_METHOD("load_dds_from_buffer", "buffer"), &Image::load_dds_from_buffer);
ClassDB::bind_method(D_METHOD("load_exr_from_buffer", "buffer"), &Image::load_exr_from_buffer);
ClassDB::bind_method(D_METHOD("load_svg_from_buffer", "buffer", "scale"), &Image::load_svg_from_buffer, DEFVAL(1.0));
ClassDB::bind_method(D_METHOD("load_svg_from_string", "svg_str", "scale"), &Image::load_svg_from_string, DEFVAL(1.0));
@ -4424,6 +4425,14 @@ Error Image::load_jpg_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _jpg_mem_loader_func);
}
Error Image::load_exr_from_buffer(const Vector<uint8_t> &p_array) {
ERR_FAIL_NULL_V_MSG(
_exr_mem_loader_func,
ERR_UNAVAILABLE,
"The TinyEXR module isn't enabled. Recompile the Godot editor or export template binary with the `tinyexr_export_templates=yes` SCons option.");
return _load_from_buffer(p_array, _exr_mem_loader_func);
}
Error Image::load_webp_from_buffer(const Vector<uint8_t> &p_array) {
return _load_from_buffer(p_array, _webp_mem_loader_func);
}

View file

@ -219,6 +219,7 @@ public:
static inline ScalableImageMemLoadFunc _svg_scalable_mem_loader_func = nullptr;
static inline ImageMemLoadFunc _ktx_mem_loader_func = nullptr;
static inline ImageMemLoadFunc _dds_mem_loader_func = nullptr;
static inline ImageMemLoadFunc _exr_mem_loader_func = nullptr;
// External VRAM compression function pointers.
@ -429,6 +430,7 @@ public:
Error load_bmp_from_buffer(const Vector<uint8_t> &p_array);
Error load_ktx_from_buffer(const Vector<uint8_t> &p_array);
Error load_dds_from_buffer(const Vector<uint8_t> &p_array);
Error load_exr_from_buffer(const Vector<uint8_t> &p_array);
Error load_svg_from_buffer(const Vector<uint8_t> &p_array, float scale = 1.0);
Error load_svg_from_string(const String &p_svg_str, float scale = 1.0);