3 * @brief IMage Buffer module.
5 * This module offers import/export of several graphical file formats.
10 * @page IMB - Imbuf module external interface
13 * @section about About the IMB module
15 * External interface of the IMage Buffer module. This module offers
16 * import/export of several graphical file formats. It offers the
17 * ImBuf type as a common structure to refer to different graphical
18 * file formats, and to enable a uniform way of handling them.
20 * @section issues Known issues with IMB
22 * - imbuf is written in C.
23 * - Endianness issues are dealt with internally.
24 * - File I/O must be done externally. The module uses FILE*'s to
25 * direct input/output.
26 * - Platform dependency is limited. Some minor patches for
27 * amiga and Irix are present. A 'posix-compliancy-patch'
28 * provides the interface to windows.
30 * @section dependencies Dependencies
34 * The listbase types are used for handling the memory
37 * blenlib handles guarded memory management in blender-style.
38 * BLI_winstuff.h makes a few windows specific behaviours
44 * ***** BEGIN GPL LICENSE BLOCK *****
46 * This program is free software; you can redistribute it and/or
47 * modify it under the terms of the GNU General Public License
48 * as published by the Free Software Foundation; either version 2
49 * of the License, or (at your option) any later version.
51 * This program is distributed in the hope that it will be useful,
52 * but WITHOUT ANY WARRANTY; without even the implied warranty of
53 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
54 * GNU General Public License for more details.
56 * You should have received a copy of the GNU General Public License
57 * along with this program; if not, write to the Free Software Foundation,
58 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
60 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
61 * All rights reserved.
63 * The Original Code is: all of this file.
65 * Contributor(s): none yet.
67 * ***** END GPL LICENSE BLOCK *****
75 * @attention defined in ???
81 * @attention defined in ???
87 * @attention Defined in allocimbuf.c
94 * @attention Defined in readimage.c
96 struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, int size, int flags);
100 * @attention Defined in readimage.c
102 struct ImBuf *IMB_testiffname(char *naam,int flags);
106 * @attention Defined in readimage.c
108 struct ImBuf *IMB_loadiffname(const char *naam, int flags);
112 * @attention Defined in allocimbuf.c
114 void IMB_freeImBuf(struct ImBuf *ibuf);
118 * @attention Defined in allocimbuf.c
120 struct ImBuf *IMB_allocImBuf(short x, short y,
121 unsigned char d, unsigned int flags,
122 unsigned char bitmap);
126 * Increase reference count to imbuf
127 * (to delete an imbuf you have to call freeImBuf as many times as it
130 * @attention Defined in allocimbuf.c
133 void IMB_refImBuf(struct ImBuf *ibuf);
137 * @attention Defined in allocimbuf.c
139 void IMB_cache_limiter_insert(struct ImBuf *i);
140 void IMB_cache_limiter_unmanage(struct ImBuf *i);
141 void IMB_cache_limiter_touch(struct ImBuf *i);
142 void IMB_cache_limiter_ref(struct ImBuf *i);
143 void IMB_cache_limiter_unref(struct ImBuf *i);
144 int IMB_cache_limiter_get_refcount(struct ImBuf *i);
146 void IMB_free_cache_limiter(void);
150 * @attention Defined in allocimbuf.c
152 struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1);
156 * @attention Defined in allocimbuf.c
158 short addzbufImBuf(struct ImBuf *ibuf);
159 short addzbuffloatImBuf(struct ImBuf *ibuf);
163 * @attention Defined in rectop.c
166 typedef enum IMB_BlendMode {
171 IMB_BLEND_LIGHTEN = 4,
172 IMB_BLEND_DARKEN = 5,
173 IMB_BLEND_ERASE_ALPHA = 6,
174 IMB_BLEND_ADD_ALPHA = 7,
176 IMB_BLEND_COPY = 1000,
177 IMB_BLEND_COPY_RGB = 1001,
178 IMB_BLEND_COPY_ALPHA = 1002
181 unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac,
183 void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac,
186 void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx,
187 int *desty, int *srcx, int *srcy, int *width, int *height);
188 void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx,
189 int desty, int srcx, int srcy, int width, int height);
190 void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
191 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
194 * Return the length (in frames) of the given @a anim.
196 int IMB_anim_get_duration(struct anim *anim);
200 * @attention Defined in anim.c
202 struct anim *IMB_open_anim(const char *name, int ib_flags);
203 void IMB_close_anim(struct anim *anim);
207 * @attention Defined in anim.c
210 int ismovie(char *name);
211 void IMB_anim_set_preseek(struct anim *anim, int preseek);
212 int IMB_anim_get_preseek(struct anim *anim);
216 * @attention Defined in anim.c
219 struct ImBuf *IMB_anim_absolute(struct anim *anim, int position);
223 * @attention Defined in anim.c
224 * fetches a define previewframe, usually half way into the movie
226 struct ImBuf *IMB_anim_previewframe(struct anim *anim);
230 * @attention Defined in anim.c
232 void IMB_free_anim_ibuf(struct anim *anim);
236 * @attention Defined in anim.c
238 void IMB_free_anim(struct anim *anim);
242 * @attention Defined in filter.c
244 void IMB_filter(struct ImBuf *ibuf);
245 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
246 void IMB_filter_extend(struct ImBuf *ibuf, char *mask);
247 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
248 struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level);
252 * @attention Defined in cache.c
255 void IMB_tile_cache_params(int totthread, int maxmem);
256 unsigned int *IMB_gettile(struct ImBuf *ibuf, int tx, int ty, int thread);
257 void IMB_tiles_to_rect(struct ImBuf *ibuf);
261 * @attention Defined in filter.c
263 void IMB_filtery(struct ImBuf *ibuf);
267 * @attention Defined in scaling.c
269 struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
273 * @attention Defined in scaling.c
275 struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, short newx, short newy);
279 * @attention Defined in scaling.c
281 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy);
285 * @attention Defined in writeimage.c
287 short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags);
290 * Encodes a png image from an ImBuf
292 * @attention Defined in png_encode.c
294 short IMB_png_encode(struct ImBuf *ibuf, int file, int flags);
298 * @attention Defined in util.c
300 int IMB_ispic(char *name);
304 * @attention Defined in util.c
306 int IMB_isanim(char *name);
310 * @attention Defined in util.c
312 int imb_get_anim_type(char *name);
316 * @attention Defined in divers.c
318 void IMB_de_interlace(struct ImBuf *ibuf);
319 void IMB_interlace(struct ImBuf *ibuf);
320 void IMB_rect_from_float(struct ImBuf *ibuf);
321 void IMB_float_from_rect(struct ImBuf *ibuf);
324 * Change the ordering of the color bytes pointed to by rect from
325 * rgba to abgr. size * 4 color bytes are reordered.
327 * @attention Defined in imageprocess.c
329 void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
332 * Change the ordering of the color bytes pointed to by rect from
333 * rgba to abgr. size * 4 color bytes are reordered.
335 * @attention Defined in imageprocess.c
337 void IMB_convert_bgra_to_rgba(int size, unsigned int *rect);
341 * @attention defined in imageprocess.c
343 void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
344 void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
345 void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
347 void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
348 void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
349 void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
350 void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
354 * @attention defined in readimage.c
355 * @deprecated Only here for backwards compatibility of the
356 * @deprecated plugin system.
358 struct ImBuf *IMB_loadiffmem(int *mem, int flags);
362 * @attention defined in readimage.c
363 * @deprecated Only here for backwards compatibility of the
364 * @deprecated plugin system.
366 struct ImBuf *IMB_loadifffile(int file, int flags);
370 * @attention defined in scaling.c
372 struct ImBuf *IMB_half_x(struct ImBuf *ibuf1);
376 * @attention defined in scaling.c
378 struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1);
382 * @attention defined in scaling.c
384 struct ImBuf *IMB_double_x(struct ImBuf *ibuf1);
388 * @attention defined in scaling.c
390 struct ImBuf *IMB_half_y(struct ImBuf *ibuf1);
394 * @attention defined in scaling.c
396 struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1);
400 * @attention defined in scaling.c
402 struct ImBuf *IMB_double_y(struct ImBuf *ibuf1);
406 * @attention Defined in rotate.c
408 void IMB_flipx(struct ImBuf *ibuf);
409 void IMB_flipy(struct ImBuf *ibuf);
411 /* Premultiply alpha */
413 void IMB_premultiply_alpha(struct ImBuf *ibuf);
417 * @attention Defined in allocimbuf.c
419 void IMB_freezbufImBuf(struct ImBuf *ibuf);
420 void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
424 * @attention Defined in rectop.c
426 void IMB_rectfill(struct ImBuf *drect, float col[4]);
427 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
429 /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
430 void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
432 /* defined in metadata.c */
433 int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
435 /* exported for image tools in blender, to quickly allocate 32 bits rect */
436 short imb_addrectImBuf(struct ImBuf *ibuf);
437 void imb_freerectImBuf(struct ImBuf *ibuf);
439 short imb_addrectfloatImBuf(struct ImBuf *ibuf);
440 void imb_freerectfloatImBuf(struct ImBuf *ibuf);
441 void imb_freemipmapImBuf(struct ImBuf *ibuf);
443 short imb_addtilesImBuf(struct ImBuf *ibuf);
444 void imb_freetilesImBuf(struct ImBuf *ibuf);