From ae59e22cdd7101d85bcb92871ce53f05c668f5c4 Mon Sep 17 00:00:00 2001 From: Maganty Rushyendra Date: Thu, 18 Jun 2020 16:38:45 +0800 Subject: [PATCH] Fix editor texture preview for certain specific dimensions Ensures no error is issued when attempting to preview a resource that may be scaled down to <1 pixel when resizing to fit the thumbnail. (cherry picked from commit c7a8dc7bb9959f3822480f8fe00146ff7fcb3f30) --- editor/plugins/editor_preview_plugins.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 9b0d5d3daf4..2dce70f3111 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -131,7 +131,8 @@ Ref EditorTexturePreviewPlugin::generate(const RES &p_from, const Size2 if (new_size.y > p_size.y) { new_size = Vector2(new_size.x * p_size.y / new_size.y, p_size.y); } - img->resize(new_size.x, new_size.y, Image::INTERPOLATE_CUBIC); + Vector2i new_size_i(MAX(1, (int)new_size.x), MAX(1, (int)new_size.y)); + img->resize(new_size_i.x, new_size_i.y, Image::INTERPOLATE_CUBIC); post_process_preview(img);