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 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.
85 * This program is distributed in the hope that it will be useful,
86 * but WITHOUT ANY WARRANTY; without even the implied warranty of
87 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88 * GNU General Public License for more details.
90 * You should have received a copy of the GNU General Public License
91 * along with this program; if not, write to the Free Software Foundation,
92 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
94 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
95 * All rights reserved.
97 * The Original Code is: all of this file.
99 * Contributor(s): none yet.
101 * ***** END GPL LICENSE BLOCK *****
108 * @attention defined in ???
114 * @attention defined in ???
120 * @attention Defined in cmap.c
122 void IMB_freeImBufdata(void);
126 * @attention Defined in cmap.c
128 void IMB_applycmap(struct ImBuf *ibuf);
132 * @attention Defined in cmap.c
134 short IMB_converttocmap(struct ImBuf *ibuf);
138 * @attention Defined in cmap.c
140 int IMB_alpha_to_col0(int value);
144 * @attention Defined in readimage.c
146 struct ImBuf *IMB_ibImageFromMemory(int *mem, int size, int flags);
150 * @attention Defined in readimage.c
152 struct ImBuf *IMB_testiffname(char *naam,int flags);
156 * @attention Defined in readimage.c
158 struct ImBuf *IMB_loadiffname(const char *naam, int flags);
162 * @attention Defined in allocimbuf.c
164 void IMB_freeImBuf(struct ImBuf * ibuf);
168 * @attention Defined in allocimbuf.c
170 struct ImBuf *IMB_allocImBuf(short x, short y,
171 unsigned char d, unsigned int flags,
172 unsigned char bitmap);
176 * Increase reference count to imbuf
177 * (to delete an imbuf you have to call freeImBuf as many times as it
180 * @attention Defined in allocimbuf.c
183 void IMB_refImBuf(struct ImBuf * ibuf);
187 * @attention Defined in allocimbuf.c
189 void IMB_cache_limiter_insert(struct ImBuf * i);
190 void IMB_cache_limiter_unmanage(struct ImBuf * i);
191 void IMB_cache_limiter_touch(struct ImBuf * i);
192 void IMB_cache_limiter_ref(struct ImBuf * i);
193 void IMB_cache_limiter_unref(struct ImBuf * i);
194 int IMB_cache_limiter_get_refcount(struct ImBuf * i);
198 * @attention Defined in allocimbuf.c
200 struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1);
204 * @attention Defined in allocimbuf.c
206 short addzbufImBuf(struct ImBuf * ibuf);
207 short addzbuffloatImBuf(struct ImBuf * ibuf);
211 * @attention Defined in allocimbuf.c
213 void IMB_freecmapImBuf(struct ImBuf * ibuf);
217 * @attention Defined in rectop.c
220 typedef enum IMB_BlendMode {
225 IMB_BLEND_LIGHTEN = 4,
226 IMB_BLEND_DARKEN = 5,
227 IMB_BLEND_ERASE_ALPHA = 6,
228 IMB_BLEND_ADD_ALPHA = 7,
230 IMB_BLEND_COPY = 1000,
231 IMB_BLEND_COPY_RGB = 1001,
232 IMB_BLEND_COPY_ALPHA = 1002
235 unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac,
237 void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac,
240 void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx,
241 int *desty, int *srcx, int *srcy, int *width, int *height);
242 void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx,
243 int desty, int srcx, int srcy, int width, int height);
244 void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
245 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
246 void IMB_rectblend_torus(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx,
247 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
250 * Return the length (in frames) of the given @a anim.
252 int IMB_anim_get_duration(struct anim *anim);
256 * @attention Defined in anim.c
258 struct anim * IMB_open_anim(const char * name, int ib_flags);
259 void IMB_close_anim(struct anim * anim);
263 * @attention Defined in anim.c
266 int ismovie(char *name);
267 void IMB_anim_set_preseek(struct anim * anim, int preseek);
268 int IMB_anim_get_preseek(struct anim * anim);
272 * @attention Defined in anim.c
275 struct ImBuf * IMB_anim_absolute(struct anim * anim, int position);
279 * @attention Defined in anim.c
280 * fetches a define previewframe, usually half way into the movie
282 struct ImBuf * IMB_anim_previewframe(struct anim * anim);
286 * @attention Defined in anim.c
288 void IMB_free_anim_ibuf(struct anim * anim);
292 * @attention Defined in anim.c
294 void IMB_free_anim(struct anim * anim);
298 * @attention Defined in anim.c
300 struct ImBuf * IMB_anim_nextpic(struct anim * anim);
305 * @attention Defined in antialias.c
307 void IMB_clever_double (struct ImBuf * ibuf);
311 * @attention Defined in antialias.c
313 void IMB_antialias(struct ImBuf * ibuf);
317 * @attention Defined in filter.c
319 void IMB_filter(struct ImBuf *ibuf);
320 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
321 void IMB_filter_extend(struct ImBuf *ibuf, char *mask);
322 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter, int SAT);
326 * @attention Defined in filter.c
328 void IMB_filtery(struct ImBuf *ibuf);
332 * @attention Defined in scaling.c
334 struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
338 * @attention Defined in scaling.c
340 struct ImBuf *IMB_scaleImBuf(struct ImBuf * ibuf, short newx, short newy);
344 * @attention Defined in scaling.c
346 struct ImBuf *IMB_scalefieldImBuf(struct ImBuf *ibuf, short newx, short newy);
350 * @attention Defined in scaling.c
352 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, short newx, short newy);
356 * @attention Defined in writeimage.c
358 short IMB_saveiff(struct ImBuf *ibuf,char *naam,int flags);
361 * Encodes a png image from an ImBuf
363 * @attention Defined in png_encode.c
365 short IMB_png_encode(struct ImBuf *ibuf, int file, int flags);
369 * @attention Defined in util.c
371 int IMB_ispic(char *name);
375 * @attention Defined in util.c
377 int IMB_isanim(char * name);
381 * @attention Defined in util.c
383 int imb_get_anim_type(char * name);
387 * @attention Defined in divers.c
389 void IMB_de_interlace(struct ImBuf *ibuf);
390 void IMB_interlace(struct ImBuf *ibuf);
391 void IMB_gamwarp(struct ImBuf *ibuf, double gamma);
392 void IMB_rect_from_float(struct ImBuf *ibuf);
393 void IMB_float_from_rect(struct ImBuf *ibuf);
396 * Change the ordering of the color bytes pointed to by rect from
397 * rgba to abgr. size * 4 color bytes are reordered.
399 * @attention Defined in imageprocess.c
401 void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
404 * @attention defined in imageprocess.c
406 void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
407 void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
408 void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
410 void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
411 void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
412 void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
413 void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
416 * Change the ordering of the color bytes pointed to by rect from
417 * rgba to abgr. size * 4 color bytes are reordered.
419 * @attention Defined in imageprocess.c
421 void IMB_convert_bgra_to_rgba(int size, unsigned int *rect);
425 * @attention defined in scaling.c
427 struct ImBuf *IMB_scalefastfieldImBuf(struct ImBuf *ibuf,
433 * @attention defined in readimage.c
434 * @deprecated Only here for backwards compatibility of the
435 * @deprecated plugin system.
437 struct ImBuf *IMB_loadiffmem(int *mem, int flags);
441 * @attention defined in readimage.c
442 * @deprecated Only here for backwards compatibility of the
443 * @deprecated plugin system.
445 struct ImBuf *IMB_loadifffile(int file, int flags);
449 * @attention defined in scaling.c
451 struct ImBuf *IMB_half_x(struct ImBuf *ibuf1);
455 * @attention defined in scaling.c
457 struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1);
461 * @attention defined in scaling.c
463 struct ImBuf *IMB_double_x(struct ImBuf *ibuf1);
467 * @attention defined in scaling.c
469 struct ImBuf *IMB_half_y(struct ImBuf *ibuf1);
473 * @attention defined in scaling.c
475 struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1);
479 * @attention defined in scaling.c
481 struct ImBuf *IMB_double_y(struct ImBuf *ibuf1);
485 * @attention defined in scaling.c
487 struct ImBuf *IMB_onethird(struct ImBuf *ibuf1);
491 * @attention defined in scaling.c
493 struct ImBuf *IMB_halflace(struct ImBuf *ibuf1);
497 * @attention defined in dither.c
499 void IMB_dit2(struct ImBuf * ibuf, short ofs, short bits);
503 * @attention defined in dither.c
505 void IMB_dit0(struct ImBuf * ibuf, short ofs, short bits);
507 /** Externally used vars: fortunately they do not use funny types */
510 * boolean toggle that tells whether or not to
511 * scale the color map in the y-direction.
513 * @attention declared in hamx.c
515 extern int scalecmapY;
518 * This 'matrix' defines the transformation from rgb to bw color
519 * maps. You need to do a sort of dot-product for that. It is a matrix
520 * with fixed coefficients, extracted from some book.
522 * @attention Defined in matrix.h, only included in hamx.c
524 extern float rgb_to_bw[4][4];
528 * @attention Defined in rotate.c
530 void IMB_flipx(struct ImBuf *ibuf);
531 void IMB_flipy(struct ImBuf * ibuf);
535 * @attention Defined in cspace.c
537 void IMB_cspace(struct ImBuf *ibuf, float mat[][4]);
541 * @attention Defined in allocimbuf.c
543 void IMB_freezbufImBuf(struct ImBuf * ibuf);
544 void IMB_freezbuffloatImBuf(struct ImBuf * ibuf);
548 * @attention Defined in rectop.c
550 void IMB_rectfill(struct ImBuf *drect, float col[4]);
551 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
553 /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
554 void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2);
556 /* defined in imginfo.c */
557 int IMB_imginfo_change_field(struct ImBuf *img, const char *key, const char *field);
559 /* exported for image tools in blender, to quickly allocate 32 bits rect */
560 short imb_addrectImBuf(struct ImBuf * ibuf);
561 void imb_freerectImBuf(struct ImBuf * ibuf);
563 short imb_addrectfloatImBuf(struct ImBuf * ibuf);
564 void imb_freerectfloatImBuf(struct ImBuf * ibuf);
565 void imb_freemipmapImBuf(struct ImBuf * ibuf);
567 #ifdef WITH_QUICKTIME
570 * @attention Defined in quicktime_import.c
572 void quicktime_init(void);
576 * @attention Defined in quicktime_import.c
578 void quicktime_exit(void);
580 #endif //WITH_QUICKTIME
582 /* intern/dynlibtiff.c */
583 void libtiff_init(void);
584 void libtiff_exit(void);