Blender V2.61 - r43446

IMB_imbuf.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00071 #ifndef IMB_IMBUF_H
00072 #define IMB_IMBUF_H
00073 
00078 struct ImBuf;
00079 
00084 struct anim;
00085 
00090 void IMB_init(void);
00091 void IMB_exit(void);
00092 
00097 struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size,
00098                                     int flags, const char *descr);
00099 
00104 struct ImBuf *IMB_testiffname(const char *filepath, int flags);
00105 
00110 struct ImBuf *IMB_loadiffname(const char *filepath, int flags);
00111 
00116 void IMB_freeImBuf(struct ImBuf *ibuf);
00117 
00122 struct ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y,
00123                              unsigned char d, unsigned int flags);
00124 
00134 void IMB_refImBuf(struct ImBuf *ibuf);
00135 struct ImBuf * IMB_makeSingleUser(struct ImBuf *ibuf);
00136 
00141 struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1);
00142 
00147 short addzbufImBuf(struct ImBuf *ibuf);
00148 short addzbuffloatImBuf(struct ImBuf *ibuf);
00149 
00155 typedef enum IMB_BlendMode {
00156     IMB_BLEND_MIX = 0,
00157     IMB_BLEND_ADD = 1,
00158     IMB_BLEND_SUB = 2,
00159     IMB_BLEND_MUL = 3,
00160     IMB_BLEND_LIGHTEN = 4,
00161     IMB_BLEND_DARKEN = 5,
00162     IMB_BLEND_ERASE_ALPHA = 6,
00163     IMB_BLEND_ADD_ALPHA = 7,
00164 
00165     IMB_BLEND_COPY = 1000,
00166     IMB_BLEND_COPY_RGB = 1001,
00167     IMB_BLEND_COPY_ALPHA = 1002
00168 } IMB_BlendMode;
00169 
00170 unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac,
00171     IMB_BlendMode mode);
00172 void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac,
00173     IMB_BlendMode mode);
00174 
00175 void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx, 
00176     int *desty, int *srcx, int *srcy, int *width, int *height);
00177 void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx,
00178     int desty, int srcx, int srcy, int width, int height);
00179 void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, 
00180     int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode);
00181 
00187 typedef enum IMB_Timecode_Type {
00188     IMB_TC_NONE       = 0, /* don't use timecode files at all */
00189     IMB_TC_RECORD_RUN = 1, /* use images in the order as they are recorded 
00190                   (currently, this is the only one implemented
00191                   and is a sane default)
00192                    */
00193     IMB_TC_FREE_RUN   = 2, /* use global timestamp written by recording
00194                   device (prosumer camcorders e.g. can do
00195                   that) */
00196     IMB_TC_INTERPOLATED_REC_DATE_FREE_RUN = 4, 
00197                                /* interpolate a global timestamp using the
00198                   record date and time written by recording
00199                   device (*every* consumer camcorder can do
00200                   that :) )*/
00201     IMB_TC_RECORD_RUN_NO_GAPS = 8,
00202     IMB_TC_MAX_SLOT   = 8
00203 } IMB_Timecode_Type;
00204 
00205 typedef enum IMB_Proxy_Size {
00206     IMB_PROXY_NONE = 0,
00207     IMB_PROXY_25 = 1,
00208     IMB_PROXY_50 = 2,
00209     IMB_PROXY_75 = 4,
00210     IMB_PROXY_100 = 8,
00211     IMB_PROXY_MAX_SLOT = 4
00212 } IMB_Proxy_Size;
00213 
00214 /* defaults to BL_proxy within the directory of the animation */
00215 void IMB_anim_set_index_dir(struct anim * anim, const char * dir);
00216 
00217 int IMB_anim_index_get_frame_index(struct anim * anim, IMB_Timecode_Type tc,
00218                                    int position);
00219 
00220 /* will rebuild all used indices and proxies at once */
00221 void IMB_anim_index_rebuild(struct anim * anim, 
00222                             IMB_Timecode_Type build_tcs,
00223                             IMB_Proxy_Size build_preview_sizes,
00224                             int build_quality,
00225                             short *stop, short *do_update, float *progress);
00226 
00230 int IMB_anim_get_duration(struct anim *anim, IMB_Timecode_Type tc);
00231 
00232 
00237 int IMB_anim_get_fps(struct anim * anim, 
00238                      short * frs_sec, float * frs_sec_base);
00239 
00244 struct anim *IMB_open_anim(const char *name, int ib_flags, int streamindex);
00245 void IMB_close_anim(struct anim *anim);
00246 
00247 
00253 int ismovie(const char *filepath);
00254 void IMB_anim_set_preseek(struct anim *anim, int preseek);
00255 int IMB_anim_get_preseek(struct anim *anim);
00256 
00262 struct ImBuf *IMB_anim_absolute(
00263     struct anim *anim, int position,
00264     IMB_Timecode_Type tc        /* = 1 = IMB_TC_RECORD_RUN */, 
00265     IMB_Proxy_Size preview_size /* = 0 = IMB_PROXY_NONE */);
00266 
00272 struct ImBuf *IMB_anim_previewframe(struct anim *anim);
00273 
00278 void IMB_free_anim(struct anim *anim);
00279 
00285 #define FILTER_MASK_NULL        0
00286 #define FILTER_MASK_MARGIN      1
00287 #define FILTER_MASK_USED        2
00288 
00289 void IMB_filter(struct ImBuf *ibuf);
00290 void IMB_filterN(struct ImBuf *out, struct ImBuf *in);
00291 void IMB_mask_filter_extend(char *mask, int width, int height);
00292 void IMB_mask_clear(struct ImBuf *ibuf, char *mask, int val);
00293 void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter);
00294 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter);
00295 void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter);
00296 struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level);
00297 
00303 void IMB_tile_cache_params(int totthread, int maxmem);
00304 unsigned int *IMB_gettile(struct ImBuf *ibuf, int tx, int ty, int thread);
00305 void IMB_tiles_to_rect(struct ImBuf *ibuf);
00306 
00311 void IMB_filtery(struct ImBuf *ibuf);
00312 
00317 struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1);
00318 
00323 struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy);
00324 
00329 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy);
00330 
00335 short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags);
00336 
00342 short IMB_png_encode(struct ImBuf *ibuf, int file, int flags);
00343 
00348 int IMB_ispic(const char *name);
00349 
00354 int IMB_isanim(const char *name);
00355 
00360 int imb_get_anim_type(const char *name);
00361 
00366 void IMB_de_interlace(struct ImBuf *ibuf);
00367 void IMB_interlace(struct ImBuf *ibuf);
00368 
00369 /* create char buffer, color corrected if necessary, for ImBufs that lack one */ 
00370 void IMB_rect_from_float(struct ImBuf *ibuf);
00371 /* create char buffer for part of the image, color corrected if necessary,
00372    Changed part will be stored in buffer. This is expected to be used for texture painting updates */ 
00373 void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h);
00374 void IMB_float_from_rect(struct ImBuf *ibuf);
00375 void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */
00376 /* note, check that the conversion exists, only some are supported */
00377 void IMB_convert_profile(struct ImBuf *ibuf, int profile);
00378 float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc);
00379 void IMB_color_to_bw(struct ImBuf *ibuf);
00380 
00381 /* converting pixel buffers */
00382 void IMB_buffer_byte_from_float(unsigned char *rect_to, const float *rect_from,
00383     int channels_from, float dither, int profile_to, int profile_from, int predivide,
00384     int width, int height, int stride_to, int stride_from);
00385 void IMB_buffer_float_from_byte(float *rect_to, const unsigned char *rect_from,
00386     int profile_to, int profile_from, int predivide,
00387     int width, int height, int stride_to, int stride_from);
00388 void IMB_buffer_float_from_float(float *rect_to, const float *rect_from,
00389     int channels_from, int profile_to, int profile_from, int predivide,
00390     int width, int height, int stride_to, int stride_from);
00391 void IMB_buffer_byte_from_byte(unsigned char *rect_to, const unsigned char *rect_from,
00392     int profile_to, int profile_from, int predivide,
00393     int width, int height, int stride_to, int stride_from);
00394 
00401 void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf);
00402 
00409 void IMB_convert_bgra_to_rgba(int size, unsigned int *rect);
00410 
00415 void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
00416 void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
00417 void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout);
00418 
00419 void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
00420 void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
00421 void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
00422 void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v);
00423 
00430 struct ImBuf *IMB_loadifffile(int file, int flags, const char *descr);
00431 
00436 struct ImBuf *IMB_half_x(struct ImBuf *ibuf1);
00437 
00442 struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1);
00443 
00448 struct ImBuf *IMB_double_x(struct ImBuf *ibuf1);
00449 
00454 struct ImBuf *IMB_half_y(struct ImBuf *ibuf1);
00455 
00460 struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1);
00461 
00466 struct ImBuf *IMB_double_y(struct ImBuf *ibuf1);
00467 
00472 void IMB_flipx(struct ImBuf *ibuf);
00473 void IMB_flipy(struct ImBuf *ibuf);
00474 
00475 /* Premultiply alpha */
00476 
00477 void IMB_premultiply_alpha(struct ImBuf *ibuf);
00478 
00483 void IMB_freezbufImBuf(struct ImBuf *ibuf);
00484 void IMB_freezbuffloatImBuf(struct ImBuf *ibuf);
00485 
00490 void IMB_rectfill(struct ImBuf *drect, const float col[4]);
00491 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2);
00492 void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value);
00493 
00494 /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */
00495 void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, const float col[4], int x1, int y1, int x2, int y2);
00496 
00497 /* defined in metadata.c */
00498 int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field);
00499 
00500 /* exported for image tools in blender, to quickly allocate 32 bits rect */
00501 short imb_addrectImBuf(struct ImBuf *ibuf);
00502 void imb_freerectImBuf(struct ImBuf *ibuf);
00503 
00504 short imb_addrectfloatImBuf(struct ImBuf *ibuf);
00505 void imb_freerectfloatImBuf(struct ImBuf *ibuf);
00506 void imb_freemipmapImBuf(struct ImBuf *ibuf);
00507 
00508 short imb_addtilesImBuf(struct ImBuf *ibuf);
00509 void imb_freetilesImBuf(struct ImBuf *ibuf);
00510 
00511 #endif
00512