Fix T45451: File Browser crash on 16bits PNG image previews.

Issue was that with those files, Blender generate a float image by default, not a byte one...

Now, we ensure in two places we only get a byte imbuf for our thumbnails!
This commit is contained in:
Bastien Montagne 2015-07-16 17:26:53 +02:00
parent 4feef7d4f8
commit f2087b4830
Notes: blender-bot 2023-02-14 09:38:57 +01:00
Referenced by issue #45451, File Browser crash on large image previews
1 changed files with 10 additions and 0 deletions

View File

@ -442,6 +442,10 @@ static ImBuf *thumb_create_ex(
img->ftype = IMB_FTYPE_PNG;
img->planes = 32;
/* If we generated from a 16bit PNG e.g., we have a float rect, not a byte one - fix this. */
IMB_rect_from_float(img);
imb_freerectfloatImBuf(img);
if (IMB_saveiff(img, temp, IB_rect | IB_metadata)) {
#ifndef WIN32
chmod(temp, S_IRUSR | S_IWUSR);
@ -604,5 +608,11 @@ ImBuf *IMB_thumb_manage(const char *org_path, ThumbSize size, ThumbSource source
}
}
/* Our imbuf **must** have a valid rect (i.e. 8-bits/channels) data, we rely on this in draw code.
* However, in some cases we may end loading 16bits PNGs, which generated float buffers.
* This should be taken care of in generation step, but add also a safeguard here! */
IMB_rect_from_float(img);
imb_freerectfloatImBuf(img);
return img;
}