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
41 * avi defines import/export to the avi format. Only anim.c
42 * needs this. It uses the following functions:
49 * Additionally, it needs the types from the avi module.
50 * - external jpeg library
51 * The jpeg lib defines import/export to the jpeg format.
52 * only jpeg.c needs these. Used functions are:
54 * - jpeg_resync_to_restart
55 * - jpeg_set_marker_processor
57 * - jpeg_start_decompress
58 * - jpeg_abort_decompress
59 * - jpeg_read_scanlines
60 * - jpeg_finish_decompress
62 * - jpeg_create_decompress
64 * - jpeg_start_compress
66 * - jpeg_write_scanlines
67 * - jpeg_finish_compress
68 * - jpeg_create_compress
72 * - jpeg_destroy_compress
73 * Additionally, it needs the types from the jpeg lib.
78 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
80 * This program is free software; you can redistribute it and/or
81 * modify it under the terms of the GNU General Public License
82 * as published by the Free Software Foundation; either version 2
83 * of the License, or (at your option) any later version. The Blender
84 * Foundation also sells licenses for use in proprietary software under
85 * the Blender License. See http://www.blender.org/BL/ for information
88 * This program is distributed in the hope that it will be useful,
89 * but WITHOUT ANY WARRANTY; without even the implied warranty of
90 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
91 * GNU General Public License for more details.
93 * You should have received a copy of the GNU General Public License
94 * along with this program; if not, write to the Free Software Foundation,
95 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
97 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
98 * All rights reserved.
100 * The Original Code is: all of this file.
102 * Contributor(s): none yet.
104 * ***** END GPL/BL DUAL LICENSE BLOCK *****
111 * @attention defined in ???
117 * @attention defined in ???
123 * @attention Defined in cmap.c
125 void IMB_freeImBufdata(void);
129 * @attention Defined in cmap.c
131 void IMB_applycmap(struct ImBuf *ibuf);
135 * @attention Defined in cmap.c
137 short IMB_converttocmap(struct ImBuf *ibuf);
141 * @attention Defined in cmap.c
143 int IMB_alpha_to_col0(int value);
147 * @attention Defined in readimage.c
149 struct ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags);
153 * @attention Defined in readimage.c
155 struct ImBuf *IMB_testiffname(char *naam,int flags);
159 * @attention Defined in readimage.c
161 struct ImBuf *IMB_loadiffname(const char *naam, int flags);
165 * @attention Defined in allocimbuf.c
167 void IMB_freeImBuf(struct ImBuf * ibuf);
171 * @attention Defined in allocimbuf.c
173 struct ImBuf *IMB_allocImBuf(short x, short y,
174 unsigned char d, unsigned int flags,
175 unsigned char bitmap);
179 * Increase reference count to imbuf
180 * (to delete an imbuf you have to call freeImBuf as many times as it
183 * @attention Defined in allocimbuf.c
186 void IMB_refImBuf(struct ImBuf * ibuf);
190 * @attention Defined in allocimbuf.c
192 void IMB_cache_limiter_insert(struct ImBuf * i);
193 void IMB_cache_limiter_unmanage(struct ImBuf * i);
194 void IMB_cache_limiter_touch(struct ImBuf * i);
195 void IMB_cache_limiter_ref(struct ImBuf * i);
196 void IMB_cache_limiter_unref(struct ImBuf * i);
197 int IMB_cache_limiter_get_refcount(struct ImBuf * i);
201 * @attention Defined in allocimbuf.c
203 struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1);
207 * @attention Defined in allocimbuf.c
209 short addzbufImBuf(struct ImBuf * ibuf);
210 short addzbuffloatImBuf(struct ImBuf * ibuf);
214 * @attention Defined in allocimbuf.c
216 void IMB_freecmapImBuf(struct ImBuf * ibuf);
220 * @attention Defined in rectop.c
223 typedef enum IMB_BlendMode {
228 IMB_BLEND_LIGHTEN = 4,
229 IMB_BLEND_DARKEN = 5,
230 IMB_BLEND_ERASE_ALPHA = 6,
231 IMB_BLEND_ADD_ALPHA = 7,
233 IMB_BLEND_COPY = 1000,
234 IMB_BLEND_COPY_RGB = 1001,
235 IMB_BLEND_COPY_ALPHA = 1002
238 unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac,
240 void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac,
243 void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx,
244 int *desty, int *srcx, int *srcy, int *width, int *height);
245 void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx,
246 int desty, int srcx, int srcy, int width, int height);
247 void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
248 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
249 void IMB_rectblend_torus(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
250 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
253 * Return the length (in frames) of the given @a anim.
255 int IMB_anim_get_duration(struct anim *anim);
259 * @attention Defined in anim.c
261 struct anim * IMB_open_anim(const char * name, int ib_flags);
262 void IMB_close_anim(struct anim * anim);
266 * @attention Defined in anim.c
269 int ismovie(char *name);
270 void IMB_anim_set_preseek(struct anim * anim, int preseek);
271 int IMB_anim_get_preseek(struct anim * anim);
275 * @attention Defined in anim.c
278 struct ImBuf * IMB_anim_absolute(struct anim * anim, int position);
282 * @attention Defined in anim.c
283 * fetches a define previewframe, usually half way into the movie
285 struct ImBuf * IMB_anim_previewframe(struct anim * anim);
289 * @attention Defined in anim.c
291 void IMB_free_anim_ibuf(struct anim * anim);
295 * @attention Defined in anim.c
297 void IMB_free_anim(struct anim * anim);
301 * @attention Defined in anim.c
303 struct ImBuf * IMB_anim_nextpic(struct anim * anim);
308 * @attention Defined in antialias.c
310 void IMB_clever_double (struct ImBuf * ibuf);
314 * @attention Defined in antialias.c
316 void IMB_antialias(struct ImBuf * ibuf);
320 * @attention Defined in filter.c
322 void IMB_filter(struct ImBuf *ibuf);
323 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
324 void IMB_filter_extend(struct ImBuf *ibuf);
325 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
329 * @attention Defined in filter.c
331 void IMB_filtery(struct ImBuf *ibuf);
335 * @attention Defined in scaling.c
337 struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
341 * @attention Defined in scaling.c
343 struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy);
347 * @attention Defined in scaling.c
349 struct ImBuf *IMB_scalefieldImBuf(struct ImBuf *ibuf, short newx, short newy);
353 * @attention Defined in scaling.c
355 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy);
359 * @attention Defined in writeimage.c
361 short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags);
364 * Encodes a png image from an ImBuf
366 * @attention Defined in png_encode.c
368 short IMB_png_encode(struct ImBuf *ibuf, int file, int flags);
372 * @attention Defined in util.c
374 int IMB_ispic(char *name);
378 * @attention Defined in util.c
380 int IMB_isanim(char * name);
384 * @attention Defined in util.c
386 int imb_get_anim_type(char * name);
390 * @attention Defined in divers.c
392 void IMB_de_interlace(struct ImBuf *ibuf);
393 void IMB_interlace(struct ImBuf *ibuf);
394 void IMB_gamwarp(struct ImBuf *ibuf, double gamma);
395 void IMB_rect_from_float(struct ImBuf *ibuf);
396 void IMB_float_from_rect(struct ImBuf *ibuf);
399 * Change the ordering of the color bytes pointed to by rect from
400 * rgba to abgr. size * 4 color bytes are reordered.
402 * @attention Defined in imageprocess.c
404 void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
407 * @attention defined in imageprocess.c
409 void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float x, float y, int xout, int yout);
410 void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
411 void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
413 * Change the ordering of the color bytes pointed to by rect from
414 * rgba to abgr. size * 4 color bytes are reordered.
416 * @attention Defined in imageprocess.c
418 void IMB_convert_bgra_to_rgba(int size, unsigned int *rect);
422 * @attention defined in scaling.c
424 struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf,
430 * @attention defined in readimage.c
431 * @deprecated Only here for backwards compatibility of the
432 * @deprecated plugin system.
434 struct ImBuf *IMB_loadiffmem(int *mem, int flags);
438 * @attention defined in readimage.c
439 * @deprecated Only here for backwards compatibility of the
440 * @deprecated plugin system.
442 struct ImBuf *IMB_loadifffile(int file, int flags);
446 * @attention defined in scaling.c
448 struct ImBuf *IMB_half_x(struct ImBuf *ibuf1);
452 * @attention defined in scaling.c
454 struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1);
458 * @attention defined in scaling.c
460 struct ImBuf *IMB_double_x(struct ImBuf *ibuf1);
464 * @attention defined in scaling.c
466 struct ImBuf *IMB_half_y(struct ImBuf *ibuf1);
470 * @attention defined in scaling.c
472 struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1);
476 * @attention defined in scaling.c
478 struct ImBuf *IMB_double_y(struct ImBuf *ibuf1);
482 * @attention defined in scaling.c
484 struct ImBuf *IMB_onethird(struct ImBuf *ibuf1);
488 * @attention defined in scaling.c
490 struct ImBuf *IMB_halflace(struct ImBuf *ibuf1);
494 * @attention defined in dither.c
496 void IMB_dit2(struct ImBuf * ibuf, short ofs, short bits);
500 * @attention defined in dither.c
502 void IMB_dit0(struct ImBuf * ibuf, short ofs, short bits);
504 /** Externally used vars: fortunately they do not use funny types */
507 * boolean toggle that tells whether or not to
508 * scale the color map in the y-direction.
510 * @attention declared in hamx.c
512 extern int scalecmapY;
515 * This 'matrix' defines the transformation from rgb to bw color
516 * maps. You need to do a sort of dot-product for that. It is a matrix
517 * with fixed coefficients, extracted from some book.
519 * @attention Defined in matrix.h, only included in hamx.c
521 extern float rgb_to_bw[4][4];
525 * @attention Defined in rotate.c
527 void IMB_flipx(struct ImBuf *ibuf);
528 void IMB_flipy(struct ImBuf * ibuf);
532 * @attention Defined in cspace.c
534 void IMB_cspace(struct ImBuf *ibuf, float mat[][4]);
538 * @attention Defined in allocimbuf.c
540 void IMB_freezbufImBuf(struct ImBuf * ibuf);
541 void IMB_freezbuffloatImBuf(struct ImBuf * ibuf);
545 * @attention Defined in rectop.c
547 void IMB_rectfill(struct ImBuf *drect, float col[4]);
548 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
550 /* defined in imginfo.c */
551 int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field);
553 /* exported for image tools in blender, to quickly allocate 32 bits rect */
554 short imb_addrectImBuf(struct ImBuf * ibuf);
555 void imb_freerectImBuf(struct ImBuf * ibuf);
557 short imb_addrectfloatImBuf(struct ImBuf * ibuf);
558 void imb_freerectfloatImBuf(struct ImBuf * ibuf);
559 void imb_freemipmapImBuf(struct ImBuf * ibuf);
561 #ifdef WITH_QUICKTIME
564 * @attention Defined in quicktime_import.c
566 void quicktime_init(void);
570 * @attention Defined in quicktime_import.c
572 void quicktime_exit(void);
574 #endif //WITH_QUICKTIME
576 /* intern/dynlibtiff.c */
577 void libtiff_init(void);
578 void libtiff_exit(void);