mirror of
https://github.com/godotengine/godot.git
synced 2026-01-05 06:11:29 +03:00
Expose loading TGA images in Image.
(cherry picked from commit 7d4b3e6587)
This commit is contained in:
committed by
Rémi Verschelde
parent
f50c88ba7b
commit
850f07a4d9
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "image.h"
|
||||
|
||||
#include "core/error_macros.h"
|
||||
#include "core/hash_map.h"
|
||||
#include "core/io/image_loader.h"
|
||||
#include "core/io/resource_loader.h"
|
||||
@@ -2330,6 +2331,7 @@ void Image::fill(const Color &c) {
|
||||
ImageMemLoadFunc Image::_png_mem_loader_func = NULL;
|
||||
ImageMemLoadFunc Image::_jpg_mem_loader_func = NULL;
|
||||
ImageMemLoadFunc Image::_webp_mem_loader_func = NULL;
|
||||
ImageMemLoadFunc Image::_tga_mem_loader_func = NULL;
|
||||
|
||||
void (*Image::_image_compress_bc_func)(Image *, float, Image::CompressSource) = NULL;
|
||||
void (*Image::_image_compress_bptc_func)(Image *, float, Image::CompressSource) = NULL;
|
||||
@@ -2778,6 +2780,7 @@ void Image::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("load_png_from_buffer", "buffer"), &Image::load_png_from_buffer);
|
||||
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);
|
||||
|
||||
ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE), "_set_data", "_get_data");
|
||||
|
||||
@@ -3093,6 +3096,11 @@ Error Image::load_webp_from_buffer(const PoolVector<uint8_t> &p_array) {
|
||||
return _load_from_buffer(p_array, _webp_mem_loader_func);
|
||||
}
|
||||
|
||||
Error Image::load_tga_from_buffer(const PoolVector<uint8_t> &p_array) {
|
||||
ERR_FAIL_NULL_V_MSG(_tga_mem_loader_func, ERR_UNAVAILABLE, "TGA module was not installed.");
|
||||
return _load_from_buffer(p_array, _tga_mem_loader_func);
|
||||
}
|
||||
|
||||
Error Image::_load_from_buffer(const PoolVector<uint8_t> &p_array, ImageMemLoadFunc p_loader) {
|
||||
int buffer_size = p_array.size();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user