Fix T101245: Allow Thumbnails of > 256:1 Images

Ensure that thumbnails of images with aspect greater than 256:1 have
dimensions of at least one pixel.

See D16707 for more details

Differential Revision: https://developer.blender.org/D16707

Reviewed by Brecht Van Lommel
This commit is contained in:
Harley Acheson 2022-12-06 08:14:02 -08:00
parent 64541b242a
commit 658220e815
Notes: blender-bot 2023-02-14 08:38:11 +01:00
Referenced by issue #101245, Regression: Node Editor: Crash On Typing or Scrolling In Add Search
2 changed files with 4 additions and 4 deletions

View File

@ -2215,8 +2215,8 @@ struct ImBuf *imb_load_filepath_thumbnail_openexr(const char *filepath,
float scale_factor = MIN2(float(max_thumb_size) / float(source_w),
float(max_thumb_size) / float(source_h));
int dest_w = int(source_w * scale_factor);
int dest_h = int(source_h * scale_factor);
int dest_w = MAX2(int(source_w * scale_factor), 1);
int dest_h = MAX2(int(source_h * scale_factor), 1);
struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rectfloat);

View File

@ -112,8 +112,8 @@ struct ImBuf *imb_load_filepath_thumbnail_webp(const char *filepath,
*r_height = (size_t)config.input.height;
const float scale = (float)max_thumb_size / MAX2(config.input.width, config.input.height);
const int dest_w = (int)(config.input.width * scale);
const int dest_h = (int)(config.input.height * scale);
const int dest_w = MAX2((int)(config.input.width * scale), 1);
const int dest_h = MAX2((int)(config.input.height * scale), 1);
colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE);
struct ImBuf *ibuf = IMB_allocImBuf(dest_w, dest_h, 32, IB_rect);