summaryrefslogtreecommitdiffstats
path: root/scene/resources/texture.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2019-01-03 14:04:11 +0100
committerGitHub <noreply@github.com>2019-01-03 14:04:11 +0100
commita58c3fb4b7a9efa23546b71b4875360d7c8fc27d (patch)
tree4a3fefa8077febccba5454b848b5d1c1da43d684 /scene/resources/texture.cpp
parent6b1c3d63106f9ef32ccb42b1f9429742f9a777be (diff)
parent163e0e3ebd4c7b74307fc1ccebbf7e12266f2cf6 (diff)
downloadredot-engine-a58c3fb4b7a9efa23546b71b4875360d7c8fc27d.tar.gz
Merge pull request #24736 from timoschwarzer/ltex-thumbnails
Add thumbnails to LargeTexture
Diffstat (limited to 'scene/resources/texture.cpp')
-rw-r--r--scene/resources/texture.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index ad962a3551..2e0f04ffcb 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -1205,6 +1205,17 @@ Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture>());
return pieces[p_idx].texture;
}
+Ref<Image> LargeTexture::to_image() const {
+
+ Ref<Image> img = memnew(Image(this->get_width(), this->get_height(), false, Image::FORMAT_RGBA8));
+ for (int i = 0; i < pieces.size(); i++) {
+
+ Ref<Image> src_img = pieces[i].texture->get_data();
+ img->blit_rect(src_img, Rect2(0, 0, src_img->get_width(), src_img->get_height()), pieces[i].offset);
+ }
+
+ return img;
+}
void LargeTexture::_bind_methods() {