Commit: f2087b4830b2f59188e9c604450db5f37b6d472a
Author: Bastien Montagne
Date:   Thu Jul 16 17:26:53 2015 +0200
Branches: master
https://developer.blender.org/rBf2087b4830b2f59188e9c604450db5f37b6d472a

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!

===================================================================

M       source/blender/imbuf/intern/thumbs.c

===================================================================

diff --git a/source/blender/imbuf/intern/thumbs.c 
b/source/blender/imbuf/intern/thumbs.c
index bd74957..09e7d04 100644
--- a/source/blender/imbuf/intern/thumbs.c
+++ b/source/blender/imbuf/intern/thumbs.c
@@ -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;
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to