|
Blender
V2.59
|
00001 /* 00002 * $Id: IMB_imbuf.h 38654 2011-07-24 10:26:22Z nazgul $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00073 #ifndef IMB_IMBUF_H 00074 #define IMB_IMBUF_H 00075 00080 struct ImBuf; 00081 00086 struct anim; 00087 00092 void IMB_init(void); 00093 void IMB_exit(void); 00094 00099 struct ImBuf *IMB_ibImageFromMemory(unsigned char *mem, size_t size, int flags); 00100 00105 struct ImBuf *IMB_testiffname(char *naam,int flags); 00106 00111 struct ImBuf *IMB_loadiffname(const char *naam, int flags); 00112 00117 void IMB_freeImBuf(struct ImBuf *ibuf); 00118 00123 struct ImBuf *IMB_allocImBuf(unsigned int x, unsigned int y, 00124 unsigned char d, unsigned int flags); 00125 00135 void IMB_refImBuf(struct ImBuf *ibuf); 00136 00141 void IMB_cache_limiter_insert(struct ImBuf *i); 00142 void IMB_cache_limiter_unmanage(struct ImBuf *i); 00143 void IMB_cache_limiter_touch(struct ImBuf *i); 00144 void IMB_cache_limiter_ref(struct ImBuf *i); 00145 void IMB_cache_limiter_unref(struct ImBuf *i); 00146 int IMB_cache_limiter_get_refcount(struct ImBuf *i); 00147 00148 void IMB_free_cache_limiter(void); 00149 00154 struct ImBuf *IMB_dupImBuf(struct ImBuf *ibuf1); 00155 00160 short addzbufImBuf(struct ImBuf *ibuf); 00161 short addzbuffloatImBuf(struct ImBuf *ibuf); 00162 00168 typedef enum IMB_BlendMode { 00169 IMB_BLEND_MIX = 0, 00170 IMB_BLEND_ADD = 1, 00171 IMB_BLEND_SUB = 2, 00172 IMB_BLEND_MUL = 3, 00173 IMB_BLEND_LIGHTEN = 4, 00174 IMB_BLEND_DARKEN = 5, 00175 IMB_BLEND_ERASE_ALPHA = 6, 00176 IMB_BLEND_ADD_ALPHA = 7, 00177 00178 IMB_BLEND_COPY = 1000, 00179 IMB_BLEND_COPY_RGB = 1001, 00180 IMB_BLEND_COPY_ALPHA = 1002 00181 } IMB_BlendMode; 00182 00183 unsigned int IMB_blend_color(unsigned int src1, unsigned int src2, int fac, 00184 IMB_BlendMode mode); 00185 void IMB_blend_color_float(float *dst, float *src1, float *src2, float fac, 00186 IMB_BlendMode mode); 00187 00188 void IMB_rectclip(struct ImBuf *dbuf, struct ImBuf *sbuf, int *destx, 00189 int *desty, int *srcx, int *srcy, int *width, int *height); 00190 void IMB_rectcpy(struct ImBuf *drect, struct ImBuf *srect, int destx, 00191 int desty, int srcx, int srcy, int width, int height); 00192 void IMB_rectblend(struct ImBuf *dbuf, struct ImBuf *sbuf, int destx, 00193 int desty, int srcx, int srcy, int width, int height, IMB_BlendMode mode); 00194 00198 int IMB_anim_get_duration(struct anim *anim); 00199 00204 struct anim *IMB_open_anim(const char *name, int ib_flags); 00205 void IMB_close_anim(struct anim *anim); 00206 00212 int ismovie(const char *name); 00213 void IMB_anim_set_preseek(struct anim *anim, int preseek); 00214 int IMB_anim_get_preseek(struct anim *anim); 00215 00221 struct ImBuf *IMB_anim_absolute(struct anim *anim, int position); 00222 00228 struct ImBuf *IMB_anim_previewframe(struct anim *anim); 00229 00234 void IMB_free_anim_ibuf(struct anim *anim); 00235 00240 void IMB_free_anim(struct anim *anim); 00241 00247 #define FILTER_MASK_NULL 0 00248 #define FILTER_MASK_MARGIN 1 00249 #define FILTER_MASK_USED 2 00250 00251 void IMB_filter(struct ImBuf *ibuf); 00252 void IMB_filterN(struct ImBuf *out, struct ImBuf *in); 00253 void IMB_mask_filter_extend(char *mask, int width, int height); 00254 void IMB_mask_clear(struct ImBuf *ibuf, char *mask, int val); 00255 void IMB_filter_extend(struct ImBuf *ibuf, char *mask, int filter); 00256 void IMB_makemipmap(struct ImBuf *ibuf, int use_filter); 00257 void IMB_remakemipmap(struct ImBuf *ibuf, int use_filter); 00258 struct ImBuf *IMB_getmipmap(struct ImBuf *ibuf, int level); 00259 00265 void IMB_tile_cache_params(int totthread, int maxmem); 00266 unsigned int *IMB_gettile(struct ImBuf *ibuf, int tx, int ty, int thread); 00267 void IMB_tiles_to_rect(struct ImBuf *ibuf); 00268 00273 void IMB_filtery(struct ImBuf *ibuf); 00274 00279 struct ImBuf *IMB_onehalf(struct ImBuf *ibuf1); 00280 00285 struct ImBuf *IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); 00286 00291 struct ImBuf *IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy); 00292 00297 short IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags); 00298 00304 short IMB_png_encode(struct ImBuf *ibuf, int file, int flags); 00305 00310 int IMB_ispic(const char *name); 00311 00316 int IMB_isanim(const char *name); 00317 00322 int imb_get_anim_type(const char *name); 00323 00328 void IMB_de_interlace(struct ImBuf *ibuf); 00329 void IMB_interlace(struct ImBuf *ibuf); 00330 00331 /* create char buffer, color corrected if necessary, for ImBufs that lack one */ 00332 void IMB_rect_from_float(struct ImBuf *ibuf); 00333 /* create char buffer for part of the image, color corrected if necessary, 00334 Changed part will be stored in buffer. This is expected to be used for texture painting updates */ 00335 void IMB_partial_rect_from_float(struct ImBuf *ibuf, float *buffer, int x, int y, int w, int h); 00336 void IMB_float_from_rect(struct ImBuf *ibuf); 00337 void IMB_float_from_rect_simple(struct ImBuf *ibuf); /* no profile conversion */ 00338 /* note, check that the conversion exists, only some are supported */ 00339 void IMB_convert_profile(struct ImBuf *ibuf, int profile); 00340 float *IMB_float_profile_ensure(struct ImBuf *ibuf, int profile, int *alloc); 00341 void IMB_color_to_bw(struct ImBuf *ibuf); 00342 00349 void IMB_convert_rgba_to_abgr(struct ImBuf *ibuf); 00350 00357 void IMB_convert_bgra_to_rgba(int size, unsigned int *rect); 00358 00363 void bicubic_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); 00364 void neareast_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); 00365 void bilinear_interpolation(struct ImBuf *in, struct ImBuf *out, float u, float v, int xout, int yout); 00366 00367 void bicubic_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); 00368 void neareast_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); 00369 void bilinear_interpolation_color(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); 00370 void bilinear_interpolation_color_wrap(struct ImBuf *in, unsigned char *col, float *col_float, float u, float v); 00371 00378 struct ImBuf *IMB_loadiffmem(int *mem, int flags); 00379 00386 struct ImBuf *IMB_loadifffile(int file, int flags); 00387 00392 struct ImBuf *IMB_half_x(struct ImBuf *ibuf1); 00393 00398 struct ImBuf *IMB_double_fast_x(struct ImBuf *ibuf1); 00399 00404 struct ImBuf *IMB_double_x(struct ImBuf *ibuf1); 00405 00410 struct ImBuf *IMB_half_y(struct ImBuf *ibuf1); 00411 00416 struct ImBuf *IMB_double_fast_y(struct ImBuf *ibuf1); 00417 00422 struct ImBuf *IMB_double_y(struct ImBuf *ibuf1); 00423 00428 void IMB_flipx(struct ImBuf *ibuf); 00429 void IMB_flipy(struct ImBuf *ibuf); 00430 00431 /* Premultiply alpha */ 00432 00433 void IMB_premultiply_alpha(struct ImBuf *ibuf); 00434 00439 void IMB_freezbufImBuf(struct ImBuf *ibuf); 00440 void IMB_freezbuffloatImBuf(struct ImBuf *ibuf); 00441 00446 void IMB_rectfill(struct ImBuf *drect, const float col[4]); 00447 void IMB_rectfill_area(struct ImBuf *ibuf, float *col, int x1, int y1, int x2, int y2); 00448 void IMB_rectfill_alpha(struct ImBuf *ibuf, const float value); 00449 00450 /* this should not be here, really, we needed it for operating on render data, IMB_rectfill_area calls it */ 00451 void buf_rectfill_area(unsigned char *rect, float *rectf, int width, int height, float *col, int x1, int y1, int x2, int y2); 00452 00453 /* defined in metadata.c */ 00454 int IMB_metadata_change_field(struct ImBuf *img, const char *key, const char *field); 00455 00456 /* exported for image tools in blender, to quickly allocate 32 bits rect */ 00457 short imb_addrectImBuf(struct ImBuf *ibuf); 00458 void imb_freerectImBuf(struct ImBuf *ibuf); 00459 00460 short imb_addrectfloatImBuf(struct ImBuf *ibuf); 00461 void imb_freerectfloatImBuf(struct ImBuf *ibuf); 00462 void imb_freemipmapImBuf(struct ImBuf *ibuf); 00463 00464 short imb_addtilesImBuf(struct ImBuf *ibuf); 00465 void imb_freetilesImBuf(struct ImBuf *ibuf); 00466 00467 #endif 00468