Blender V4.3
IMB_thumbs.hh File Reference

Go to the source code of this file.

Macros

#define THUMB_SIZE_MAX   (100 * 1024 * 1024)
 
#define PREVIEW_RENDER_DEFAULT_HEIGHT   128
 
#define PREVIEW_RENDER_LARGE_HEIGHT   256
 
#define THUMB_DEFAULT_HASH   "00000000000000000000000000000000"
 

Enumerations

enum  ThumbSize { THB_NORMAL , THB_LARGE , THB_FAIL }
 
enum  ThumbSource : int8_t {
  THB_SOURCE_IMAGE , THB_SOURCE_MOVIE , THB_SOURCE_BLEND , THB_SOURCE_FONT ,
  THB_SOURCE_OBJECT_IO
}
 

Functions

ImBufIMB_thumb_create (const char *filepath, ThumbSize size, ThumbSource source, ImBuf *img)
 
ImBufIMB_thumb_read (const char *file_or_lib_path, ThumbSize size)
 
void IMB_thumb_delete (const char *file_or_lib_path, ThumbSize size)
 
ImBufIMB_thumb_manage (const char *file_or_lib_path, ThumbSize size, ThumbSource source)
 
void IMB_thumb_makedirs ()
 
ImBufIMB_thumb_load_blend (const char *blen_path, const char *blen_group, const char *blen_id)
 
ImBufIMB_thumb_load_font (const char *filepath, unsigned int x, unsigned int y)
 
bool IMB_thumb_load_font_get_hash (char *r_hash)
 
ImBufIMB_font_preview (const char *filepath, unsigned int width, const float color[4])
 
void IMB_thumb_locks_acquire ()
 
void IMB_thumb_locks_release ()
 
void IMB_thumb_path_lock (const char *path)
 
void IMB_thumb_path_unlock (const char *path)
 

Macro Definition Documentation

◆ PREVIEW_RENDER_DEFAULT_HEIGHT

#define PREVIEW_RENDER_DEFAULT_HEIGHT   128

Definition at line 38 of file IMB_thumbs.hh.

Referenced by thumb_create_ex(), and UI_icon_preview_to_render_size().

◆ PREVIEW_RENDER_LARGE_HEIGHT

#define PREVIEW_RENDER_LARGE_HEIGHT   256

Definition at line 39 of file IMB_thumbs.hh.

Referenced by blend_file_thumb_from_camera(), and thumb_create_ex().

◆ THUMB_DEFAULT_HASH

#define THUMB_DEFAULT_HASH   "00000000000000000000000000000000"

Note this can also be used as versioning system, to force refreshing all thumbnails if e.g. we change some thumb generating code or so. Only used by fonts so far.

Definition at line 46 of file IMB_thumbs.hh.

Referenced by IMB_thumb_create().

◆ THUMB_SIZE_MAX

#define THUMB_SIZE_MAX   (100 * 1024 * 1024)

Don't generate thumbs for images bigger than this (100mb).

Definition at line 36 of file IMB_thumbs.hh.

Referenced by IMB_thumb_load_image().

Enumeration Type Documentation

◆ ThumbSize

enum ThumbSize

Thumbnail creation and retrieval according to the 'Thumbnail Management Standard' supported by Gimp, Gnome (Nautilus), KDE etc. Reference: http://jens.triq.net/thumbnail-spec/index.html

Enumerator
THB_NORMAL 
THB_LARGE 
THB_FAIL 

Definition at line 19 of file IMB_thumbs.hh.

◆ ThumbSource

Enumerator
THB_SOURCE_IMAGE 
THB_SOURCE_MOVIE 
THB_SOURCE_BLEND 
THB_SOURCE_FONT 
THB_SOURCE_OBJECT_IO 

Definition at line 25 of file IMB_thumbs.hh.

Function Documentation

◆ IMB_font_preview()

◆ IMB_thumb_create()

ImBuf * IMB_thumb_create ( const char * filepath,
ThumbSize size,
ThumbSource source,
ImBuf * img )

Create thumbnail for file and returns new ImBuf for thumbnail.

Parameters
filepathFile path (but not a library path!) to the thumbnail to be created.

Definition at line 485 of file thumbs.cc.

References thumb_create_ex(), THUMB_DEFAULT_HASH, thumbname_from_uri(), uri_from_filename(), and URI_MAX.

Referenced by wm_file_write().

◆ IMB_thumb_delete()

void IMB_thumb_delete ( const char * file_or_lib_path,
ThumbSize size )

Delete all thumbs for the file.

Parameters
file_or_lib_pathFile path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be deleted.

Definition at line 515 of file thumbs.cc.

References BLI_delete(), BLI_exists(), BLI_path_ncmp, FILE_MAX, thumbpath_from_uri(), uri_from_filename(), and URI_MAX.

Referenced by IMB_thumb_manage(), and wm_file_write().

◆ IMB_thumb_load_blend()

ImBuf * IMB_thumb_load_blend ( const char * blen_path,
const char * blen_group,
const char * blen_id )

Special function for loading a thumbnail embedded into a blend file.

Definition at line 65 of file thumbs_blend.cc.

References imb_thumb_load_from_blend_id(), and imb_thumb_load_from_blendfile().

Referenced by thumb_create_ex().

◆ IMB_thumb_load_font()

ImBuf * IMB_thumb_load_font ( const char * filepath,
unsigned int x,
unsigned int y )

◆ IMB_thumb_load_font_get_hash()

bool IMB_thumb_load_font_get_hash ( char * r_hash)

◆ IMB_thumb_locks_acquire()

◆ IMB_thumb_locks_release()

◆ IMB_thumb_makedirs()

void IMB_thumb_makedirs ( )

Create the necessary directories to store the thumbnails.

Definition at line 298 of file thumbs.cc.

References BLI_dir_create_recursive(), FILE_MAX, get_thumb_dir(), THB_FAIL, THB_LARGE, and THB_NORMAL.

Referenced by ED_file_init().

◆ IMB_thumb_manage()

ImBuf * IMB_thumb_manage ( const char * file_or_lib_path,
ThumbSize size,
ThumbSource source )

Create the thumb if necessary and manage failed and old thumbs. Will not attempt to (re)create thumbnails of offline files. In this case only a preexisting thumbnail is returned, or null if none was found.

Parameters
file_or_lib_pathFile path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be created/managed.

Definition at line 533 of file thumbs.cc.

References BKE_blendfile_library_path_explode(), BLI_delete(), BLI_exists(), BLI_file_attributes(), BLI_file_older(), BLI_path_ncmp, BLI_stat(), FILE_ATTR_OFFLINE, FILE_MAX, FILE_MAX_LIBEXTRA, IB_metadata, IB_rect, IMB_freeImBuf(), imb_freerectfloatImBuf(), IMB_loadiffname(), IMB_metadata_get_field(), IMB_rect_from_float(), IMB_thumb_delete(), ImBuf::metadata, STREQ, THB_FAIL, THB_LARGE, THB_NORMAL, THB_SOURCE_BLEND, thumb_create_or_fail(), thumbhash_from_path(), thumbpath_from_uri(), thumbpathname_from_uri(), uri_from_filename(), and URI_MAX.

Referenced by BKE_previewimg_ensure(), file_draw_tooltip_custom_func(), and filelist_cache_preview_runf().

◆ IMB_thumb_path_lock()

◆ IMB_thumb_path_unlock()

◆ IMB_thumb_read()

ImBuf * IMB_thumb_read ( const char * file_or_lib_path,
ThumbSize size )

Read thumbnail for file and returns new ImBuf for thumbnail.

Parameters
file_or_lib_pathFile path or library-ID path (e.g. /a/b.blend/Material/MyMaterial) to the thumbnail to be read.

Definition at line 499 of file thumbs.cc.

References FILE_MAX, IB_metadata, IB_rect, IMB_loadiffname(), thumbpath_from_uri(), uri_from_filename(), and URI_MAX.

Referenced by file_draw_tooltip_custom_func(), and uiTemplateRecentFiles_tooltip_func().