diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-05-25 01:52:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-05-25 01:52:18 +0400 |
commit | c61e25e6ac37296c13c0949b8363cc168125d750 (patch) | |
tree | 2bab770f7158ad937b6b7ccddea6480c8d594d90 /source/blender/imbuf/intern/thumbs.c | |
parent | 3332b2b29e0b63a9768856c363dda3a4e52f4ce9 (diff) |
blend file thumbnailing
- uses same thumbnail system as image browser
- blend files show thumbnails in ubuntu/gnome (freedesktop spec)
- 128x128 images are embedded into the blend file header, a simple loader avoids reading the entire blend file to extract it when generating thumbnails in the file selector.
When the image browser reads a directory it loads images and creates thumbnails, blend files embedded images are treated just like loading an image.
- the thumbnail is created from the camera view in solid mode. (no camera == no thumbnal).
- readfile/writefile.c: had to use the 'TEST' code name to save thumbnails, anything else would segfault older blender versions on load. (its not used elsewhere).
Diffstat (limited to 'source/blender/imbuf/intern/thumbs.c')
-rw-r--r-- | source/blender/imbuf/intern/thumbs.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/source/blender/imbuf/intern/thumbs.c b/source/blender/imbuf/intern/thumbs.c index 45fbf49dbbd..8c75f5ab1ab 100644 --- a/source/blender/imbuf/intern/thumbs.c +++ b/source/blender/imbuf/intern/thumbs.c @@ -241,9 +241,8 @@ void IMB_thumb_makedirs() } /* create thumbnail for file and returns new imbuf for thumbnail */ -ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source) +ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source, ImBuf *img) { - ImBuf *img = 0; char uri[URI_MAX]; char desc[URI_MAX+22]; char tpath[FILE_MAX]; @@ -285,8 +284,18 @@ ImBuf* IMB_thumb_create(const char* path, ThumbSize size, ThumbSource source) img = IMB_allocImBuf(0,0,32, IB_rect | IB_metadata, 0); if (!img) return 0; } else { - if (THB_SOURCE_IMAGE == source) { - img = IMB_loadiffname(path, IB_rect | IB_metadata); + if (THB_SOURCE_IMAGE == source || THB_SOURCE_BLEND == source) { + + /* only load if we didnt give an image */ + if(img==NULL) { + if(THB_SOURCE_BLEND == source) { + img = IMB_loadblend_thumb(path); + } + else { + img = IMB_loadiffname(path, IB_rect | IB_metadata); + } + } + if (img != NULL) { stat(path, &info); sprintf(mtime, "%ld", info.st_mtime); @@ -425,10 +434,10 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) IMB_thumb_delete(path, THB_NORMAL); IMB_thumb_delete(path, THB_LARGE); IMB_thumb_delete(path, THB_FAIL); - img = IMB_thumb_create(path, size, source); + img = IMB_thumb_create(path, size, source, NULL); if(!img){ /* thumb creation failed, write fail thumb */ - img = IMB_thumb_create(path, THB_FAIL, source); + img = IMB_thumb_create(path, THB_FAIL, source, NULL); if (img) { /* we don't need failed thumb anymore */ IMB_freeImBuf(img); @@ -438,10 +447,10 @@ ImBuf* IMB_thumb_manage(const char* path, ThumbSize size, ThumbSource source) } } } else { - img = IMB_thumb_create(path, size, source); + img = IMB_thumb_create(path, size, source, NULL); if(!img){ /* thumb creation failed, write fail thumb */ - img = IMB_thumb_create(path, THB_FAIL, source); + img = IMB_thumb_create(path, THB_FAIL, source, NULL); if (img) { /* we don't need failed thumb anymore */ IMB_freeImBuf(img); |