Changeset View
Changeset View
Standalone View
Standalone View
source/blender/imbuf/intern/thumbs.c
| Context not available. | |||||
| #endif | #endif | ||||
| #endif | #endif | ||||
| switch (size) { | switch (size) { | ||||
| case THB_NORMAL: | case THB_NORMAL || THB_LARGE: | ||||
| subdir = "/" THUMBNAILS "/normal/"; | subdir = "/" THUMBNAILS "/normal/"; | ||||
| break; | break; | ||||
| /* large thumbnails folder is currently not used | |||||
| case THB_LARGE: | case THB_LARGE: | ||||
| subdir = "/" THUMBNAILS "/large/"; | subdir = "/" THUMBNAILS "/large/"; | ||||
| break; | break;*/ | ||||
| case THB_FAIL: | case THB_FAIL: | ||||
| subdir = "/" THUMBNAILS "/fail/blender/"; | subdir = "/" THUMBNAILS "/fail/blender/"; | ||||
| break; | break; | ||||
| Context not available. | |||||
| void IMB_thumb_makedirs(void) | void IMB_thumb_makedirs(void) | ||||
| { | { | ||||
| char tpath[FILE_MAX]; | char tpath[FILE_MAX]; | ||||
| if (get_thumb_dir(tpath, THB_NORMAL)) { | if (get_thumb_dir(tpath, THB_LARGE)) { | ||||
| BLI_dir_create_recursive(tpath); | BLI_dir_create_recursive(tpath); | ||||
| } | } | ||||
| if (get_thumb_dir(tpath, THB_FAIL)) { | if (get_thumb_dir(tpath, THB_FAIL)) { | ||||
| BLI_dir_create_recursive(tpath); | BLI_dir_create_recursive(tpath); | ||||
| } | } | ||||
| } | } | ||||
| /* get thumbnails actual numeric size from enum ThumbSize*/ | |||||
| short thumbsize_numeric_size(ThumbSize size) | |||||
| { | |||||
| switch (size) { | |||||
| case THB_NORMAL: | |||||
| return 128; | |||||
| case THB_LARGE: | |||||
| return 256; | |||||
| case THB_FAIL: | |||||
| return 1; | |||||
| default: | |||||
| return 0; /* unknown size */ | |||||
| } | |||||
| } | |||||
| /* create thumbnail for file and returns new imbuf for thumbnail */ | /* create thumbnail for file and returns new imbuf for thumbnail */ | ||||
| static ImBuf *thumb_create_ex( | static ImBuf *thumb_create_ex( | ||||
| const char *file_path, const char *uri, const char *thumb, ThumbSize size, ThumbSource source, ImBuf *img) | const char *file_path, const char *uri, const char *thumb, ThumbSize size, ThumbSource source, ImBuf *img) | ||||
| Context not available. | |||||
| float scaledx, scaledy; | float scaledx, scaledy; | ||||
| BLI_stat_t info; | BLI_stat_t info; | ||||
| switch (size) { | tsize = thumbsize_numeric_size(size); | ||||
| case THB_NORMAL: | if (!tsize) { | ||||
| tsize = 128; | return NULL; /* unknown size */ | ||||
| break; | |||||
| case THB_LARGE: | |||||
| tsize = 256; | |||||
| break; | |||||
| case THB_FAIL: | |||||
| tsize = 1; | |||||
| break; | |||||
| default: | |||||
| return NULL; /* unknown size */ | |||||
| } | } | ||||
| /* exception, skip images over 100mb */ | /* exception, skip images over 100mb */ | ||||
| Context not available. | |||||
| img = NULL; | img = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| /* check if thumbnail is out of date or too small | |||||
| (older versions thumbnails were 128x128)*/ | |||||
| time_t t = atol(mtime); | time_t t = atol(mtime); | ||||
| if (st.st_mtime != t) { | short numeric_size = thumbsize_numeric_size(size); | ||||
| if (st.st_mtime != t || (img->x < numeric_size && img->y < numeric_size)) { | |||||
| /* recreate all thumbs */ | /* recreate all thumbs */ | ||||
| IMB_freeImBuf(img); | IMB_freeImBuf(img); | ||||
| img = NULL; | img = NULL; | ||||
| Context not available. | |||||