diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index ca2d519e8a9..760b0c6bdc2 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -338,6 +338,7 @@ + Loads an image from the binary contents of a JPEG file. @@ -346,6 +347,7 @@ + Loads an image from the binary contents of a PNG file. diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index 9a5937299ce..0bff3317db1 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -47,12 +47,12 @@ - + - Load an [code]ImageTexture[/code]. + Load an [code]ImageTexture[/code] from a file path. diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index c0f6756fd1d..56a2e7afba7 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -220,12 +220,15 @@ Image::Format ImageTexture::get_format() const { return format; } -void ImageTexture::load(const String &p_path) { +Error ImageTexture::load(const String &p_path) { Ref img; img.instance(); - img->load(p_path); - create_from_image(img); + Error err = img->load(p_path); + if (err == OK) { + create_from_image(img); + } + return err; } void ImageTexture::set_data(const Ref &p_image) { diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 93d7ec4ef91..d81fd3b19b5 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -124,7 +124,7 @@ public: void set_flags(uint32_t p_flags); uint32_t get_flags() const; Image::Format get_format() const; - void load(const String &p_path); + Error load(const String &p_path); void set_data(const Ref &p_image); Ref get_data() const;