tornavis/source/blender/imbuf
Julian Eisel 3589533908 Thumbnails: Always use cached thumbnails for offline files
bd9f94e917 made it so the file browser doesn't bring files online for
the purpuse of creating their thumbnail, because that can take a while.
Instead it uses a previously cached thumbnail if available. This should
be the behavior for all cases thumbnails are requested, it's not only
the file browser that does this.

In fact it makes sense to move this into the normal function to "manage"
thumbnails (that is, load and if necessary (re)create cached
thumbnails) since there are no currently known use-cases for
different behavior.

Also, seems like the previous solution didn't work when loading ID
previews from offline .blend files. For that we need to use the path to
the .blend file to check the offline status, not the full path to the ID.

Found while working on #109234 (Use UI preview system for async loading of
file/asset previews).

Pull Request: https://projects.blender.org/blender/blender/pulls/112101
2023-09-08 16:41:44 +02:00
..
intern Thumbnails: Always use cached thumbnails for offline files 2023-09-08 16:41:44 +02:00
CMakeLists.txt License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
IMB_colormanagement.h Color management: Validate Look on View Transform changes 2023-08-17 14:38:07 +02:00
IMB_imbuf.h Cleanup: correct file names in comments after C -> C++ renaming 2023-07-31 13:02:30 +10:00
IMB_imbuf_types.h Refactor: Use ImBuf to store passes in RenderResult 2023-07-10 16:33:32 +02:00
IMB_metadata.h License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
IMB_moviecache.h License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
IMB_openexr.h License Headers: Set copyright to "Blender Authors", add AUTHORS 2023-08-16 00:20:26 +10:00
IMB_thumbs.h Thumbnails: Always use cached thumbnails for offline files 2023-09-08 16:41:44 +02:00
readme.txt

readme.txt

The following 4 steps to adding a new image format to blender, its
probably easiest to look at the png code for a clean clear example,
animation formats are a bit more complicated but very similar:

Step 1:
create a new file named after the format for example lets say we were
creating an openexr read/writer  use openexr.c
It should contain functions to match the following prototypes:

struct ImBuf *imb_loadopenexr(unsigned char *mem,int size,int flags);
/* Use one of the following depending on what's easier for your file format */
short imb_saveopenexr(struct ImBuf *ibuf, FILE myfile, int flags);
short imb_saveopenexr(struct ImBuf *ibuf, char *myfile, int flags);

/* Used to test if its the correct format
int IMB_is_openexr(void *buf);

Step 2:
Add your hooks to read and write the image format these go in
	writeimage.c and readimage.c  just look at how the others are done

Step 3:
Add in IS_openexr to blender/source/blender/imbuf/IMB_imbuf_types.h
Add in R_openexr to source/blender/makesdna/DNA_scene_types.h

Step 4:
Add your hooks to the gui.
source/blender/src/buttons_scene.c
source/blender/src/toets.c
source/blender/src/writeimage.c

Step 5:
edit the following files:
blender/source/blender/imbuf/intern/util.c
blender/source/blender/src/filesel.c
blender/source/blender/src/screendump.c
and add your extension so that your format gets recognized in the thumbnails.

Step 6:
Alter the build process:
For cmake you need to edit blender/source/blender/imbuf/CMakeLists.txt
and add in your additional files to source_files.
If you have any external library info you will also need to add that
to the various build processes.

Step 7:
Its also good to add your image format to:
makepicstring in blender/source/blender/blenkernel/intern/image.c