Blender  V3.3
IMB_filetype.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include "IMB_imbuf.h"
10 
11 /* -------------------------------------------------------------------- */
15 struct ImBuf;
16 
17 #define IM_FTYPE_FLOAT 1
18 
19 typedef struct ImFileType {
21  void (*init)(void);
23  void (*exit)(void);
24 
30  bool (*is_a)(const unsigned char *buf, size_t size);
31 
33  struct ImBuf *(*load)(const unsigned char *mem,
34  size_t size,
35  int flags,
36  char colorspace[IM_MAX_SPACE]);
38  struct ImBuf *(*load_filepath)(const char *filepath, int flags, char colorspace[IM_MAX_SPACE]);
44  struct ImBuf *(*load_filepath_thumbnail)(const char *filepath,
45  int flags,
46  size_t max_thumb_size,
47  char colorspace[IM_MAX_SPACE],
48  size_t *r_width,
49  size_t *r_height);
51  bool (*save)(struct ImBuf *ibuf, const char *filepath, int flags);
52  void (*load_tile)(struct ImBuf *ibuf,
53  const unsigned char *mem,
54  size_t size,
55  int tx,
56  int ty,
57  unsigned int *rect);
58 
59  int flag;
60 
62  int filetype;
63 
66 
67 extern const ImFileType IMB_FILE_TYPES[];
68 extern const ImFileType *IMB_FILE_TYPES_LAST;
69 
71 const ImFileType *IMB_file_type_from_ibuf(const struct ImBuf *ibuf);
72 
73 void imb_filetypes_init(void);
74 void imb_filetypes_exit(void);
75 
76 void imb_tile_cache_init(void);
77 void imb_tile_cache_exit(void);
78 
79 void imb_loadtile(struct ImBuf *ibuf, int tx, int ty, unsigned int *rect);
83 void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty);
84 
87 /* Type Specific Functions */
88 
89 /* -------------------------------------------------------------------- */
93 bool imb_is_a_png(const unsigned char *mem, size_t size);
94 struct ImBuf *imb_loadpng(const unsigned char *mem,
95  size_t size,
96  int flags,
97  char colorspace[IM_MAX_SPACE]);
98 bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags);
99 
102 /* -------------------------------------------------------------------- */
106 bool imb_is_a_targa(const unsigned char *buf, size_t size);
107 struct ImBuf *imb_loadtarga(const unsigned char *mem,
108  size_t size,
109  int flags,
110  char colorspace[IM_MAX_SPACE]);
111 bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags);
112 
115 /* -------------------------------------------------------------------- */
119 bool imb_is_a_iris(const unsigned char *mem, size_t size);
123 struct ImBuf *imb_loadiris(const unsigned char *mem,
124  size_t size,
125  int flags,
126  char colorspace[IM_MAX_SPACE]);
127 bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags);
128 
131 /* -------------------------------------------------------------------- */
135 bool imb_is_a_jp2(const unsigned char *buf, size_t size);
136 struct ImBuf *imb_load_jp2(const unsigned char *mem,
137  size_t size,
138  int flags,
139  char colorspace[IM_MAX_SPACE]);
140 struct ImBuf *imb_load_jp2_filepath(const char *filepath,
141  int flags,
142  char colorspace[IM_MAX_SPACE]);
143 bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags);
144 
147 /* -------------------------------------------------------------------- */
151 bool imb_is_a_jpeg(const unsigned char *mem, size_t size);
152 bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags);
153 struct ImBuf *imb_load_jpeg(const unsigned char *buffer,
154  size_t size,
155  int flags,
156  char colorspace[IM_MAX_SPACE]);
157 struct ImBuf *imb_thumbnail_jpeg(const char *filepath,
158  int flags,
159  size_t max_thumb_size,
160  char colorspace[IM_MAX_SPACE],
161  size_t *r_width,
162  size_t *r_height);
163 
166 /* -------------------------------------------------------------------- */
170 bool imb_is_a_bmp(const unsigned char *buf, size_t size);
171 struct ImBuf *imb_bmp_decode(const unsigned char *mem,
172  size_t size,
173  int flags,
174  char colorspace[IM_MAX_SPACE]);
175 /* Found write info at http://users.ece.gatech.edu/~slabaugh/personal/c/bitmapUnix.c */
176 bool imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags);
177 
180 /* -------------------------------------------------------------------- */
184 bool imb_is_a_cineon(const unsigned char *buf, size_t size);
185 bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags);
186 struct ImBuf *imb_load_cineon(const unsigned char *mem,
187  size_t size,
188  int flags,
189  char colorspace[IM_MAX_SPACE]);
190 
193 /* -------------------------------------------------------------------- */
197 bool imb_is_a_dpx(const unsigned char *buf, size_t size);
198 bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags);
199 struct ImBuf *imb_load_dpx(const unsigned char *mem,
200  size_t size,
201  int flags,
202  char colorspace[IM_MAX_SPACE]);
203 
206 /* -------------------------------------------------------------------- */
210 bool imb_is_a_hdr(const unsigned char *buf, size_t size);
211 struct ImBuf *imb_loadhdr(const unsigned char *mem,
212  size_t size,
213  int flags,
214  char colorspace[IM_MAX_SPACE]);
215 bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags);
216 
219 /* -------------------------------------------------------------------- */
223 void imb_inittiff(void);
224 bool imb_is_a_tiff(const unsigned char *buf, size_t size);
234 struct ImBuf *imb_loadtiff(const unsigned char *mem,
235  size_t size,
236  int flags,
237  char colorspace[IM_MAX_SPACE]);
238 void imb_loadtiletiff(
239  struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect);
254 bool imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags);
255 
258 /* -------------------------------------------------------------------- */
262 bool imb_is_a_webp(const unsigned char *buf, size_t size);
263 struct ImBuf *imb_loadwebp(const unsigned char *mem,
264  size_t size,
265  int flags,
266  char colorspace[IM_MAX_SPACE]);
267 bool imb_savewebp(struct ImBuf *ibuf, const char *name, int flags);
268 
void imb_loadtile(struct ImBuf *ibuf, int tx, int ty, unsigned int *rect)
Definition: readimage.c:355
const ImFileType * IMB_file_type_from_ibuf(const struct ImBuf *ibuf)
bool imb_save_jp2(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: jp2.c:1187
void imb_inittiff(void)
Definition: tiff.c:535
bool imb_saveiris(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: iris.c:961
bool imb_is_a_tiff(const unsigned char *buf, size_t size)
Definition: tiff.c:306
struct ImBuf * imb_bmp_decode(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: bmp.c:105
bool imb_is_a_bmp(const unsigned char *buf, size_t size)
Definition: bmp.c:93
struct ImBuf * imb_load_jpeg(const unsigned char *buffer, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: jpeg.c:448
bool imb_savepng(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: png.c:110
bool imb_savejpeg(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: jpeg.c:752
struct ImBuf * imb_loadhdr(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: radiance_hdr.c:197
bool imb_is_a_hdr(const unsigned char *buf, size_t size)
Definition: radiance_hdr.c:179
bool imb_save_dpx(struct ImBuf *buf, const char *filepath, int flags)
Definition: cineon_dpx.c:192
const ImFileType * IMB_file_type_from_ftype(int ftype)
Definition: filetype.c:233
struct ImBuf * imb_loadpng(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: png.c:524
bool imb_is_a_cineon(const unsigned char *buf, size_t size)
Definition: cineon_dpx.c:176
struct ImBuf * imb_load_jp2(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: jp2.c:303
bool imb_is_a_dpx(const unsigned char *buf, size_t size)
Definition: cineon_dpx.c:197
struct ImBuf * imb_load_cineon(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: cineon_dpx.c:181
struct ImBuf * imb_loadwebp(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: webp.c:31
bool imb_save_cineon(struct ImBuf *buf, const char *filepath, int flags)
Definition: cineon_dpx.c:171
struct ImBuf * imb_loadtiff(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: tiff.c:542
struct ImBuf * imb_loadiris(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: iris.c:238
struct ImBuf * imb_load_dpx(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: cineon_dpx.c:202
bool imb_savehdr(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: radiance_hdr.c:409
const ImFileType IMB_FILE_TYPES[]
Definition: filetype.c:29
void imb_filetypes_init(void)
Definition: filetype.c:248
bool imb_is_a_jp2(const unsigned char *buf, size_t size)
Definition: jp2.c:71
void imb_tile_cache_exit(void)
Definition: cache.c:208
bool imb_is_a_iris(const unsigned char *mem, size_t size)
Definition: iris.c:230
bool imb_savetarga(struct ImBuf *ibuf, const char *filepath, int flags)
void imb_tile_cache_tile_free(struct ImBuf *ibuf, int tx, int ty)
Definition: cache.c:142
void imb_filetypes_exit(void)
Definition: filetype.c:259
const ImFileType * IMB_FILE_TYPES_LAST
Definition: filetype.c:231
bool imb_is_a_png(const unsigned char *mem, size_t size)
Definition: png.c:48
bool imb_savetiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: tiff.c:724
bool imb_savebmp(struct ImBuf *ibuf, const char *filepath, int flags)
bool imb_is_a_targa(const unsigned char *buf, size_t size)
Definition: targa.c:400
struct ImFileType ImFileType
struct ImBuf * imb_load_jp2_filepath(const char *filepath, int flags, char colorspace[IM_MAX_SPACE])
Definition: jp2.c:322
void imb_tile_cache_init(void)
Definition: cache.c:195
bool imb_is_a_webp(const unsigned char *buf, size_t size)
Definition: webp.c:23
struct ImBuf * imb_thumbnail_jpeg(const char *filepath, int flags, size_t max_thumb_size, char colorspace[IM_MAX_SPACE], size_t *r_width, size_t *r_height)
Definition: jpeg.c:489
bool imb_savewebp(struct ImBuf *ibuf, const char *name, int flags)
bool imb_is_a_jpeg(const unsigned char *mem, size_t size)
Definition: jpeg.c:51
void imb_loadtiletiff(struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect)
Definition: tiff.c:667
struct ImBuf * imb_loadtarga(const unsigned char *mem, size_t size, int flags, char colorspace[IM_MAX_SPACE])
Definition: targa.c:612
#define IM_MAX_SPACE
Definition: IMB_imbuf.h:49
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
SyclQueue void void size_t num_bytes void
ccl_global float * buffer
char name[IMB_FILENAME_SIZE]
enum eImbFileType ftype
unsigned int * rect
void(* exit)(void)
Definition: IMB_filetype.h:23
bool(* save)(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: IMB_filetype.h:51
bool(* is_a)(const unsigned char *buf, size_t size)
Definition: IMB_filetype.h:30
void(* init)(void)
Definition: IMB_filetype.h:21
void(* load_tile)(struct ImBuf *ibuf, const unsigned char *mem, size_t size, int tx, int ty, unsigned int *rect)
Definition: IMB_filetype.h:52
int default_save_role
Definition: IMB_filetype.h:64