Blender  V2.59
BKE_image.h
Go to the documentation of this file.
00001 /*
00002  * $Id: BKE_image.h 36413 2011-05-01 14:02:40Z campbellbarton $ 
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 #ifndef BKE_IMAGE_H
00030 #define BKE_IMAGE_H
00031 
00038 #ifdef __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 struct Image;
00043 struct ImBuf;
00044 struct Tex;
00045 struct anim;
00046 struct Scene;
00047 struct Object;
00048 
00049 /* call from library */
00050 void    free_image(struct Image *me);
00051 
00052 void    BKE_stamp_info(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf);
00053 void    BKE_stamp_buf(struct Scene *scene, struct Object *camera, unsigned char *rect, float *rectf, int width, int height, int channels);
00054 int             BKE_alphatest_ibuf(struct ImBuf *ibuf);
00055 int             BKE_write_ibuf_stamp(struct Scene *scene, struct Object *camera, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
00056 int             BKE_write_ibuf(struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
00057 void    BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames);
00058 int             BKE_add_image_extension(char *string, int imtype);
00059 int             BKE_ftype_to_imtype(int ftype);
00060 int             BKE_imtype_to_ftype(int imtype);
00061 int             BKE_imtype_is_movie(int imtype);
00062 
00063 struct anim *openanim(char * name, int flags);
00064 
00065 void    image_de_interlace(struct Image *ima, int odd);
00066         
00067 void    tag_image_time(struct Image *ima);
00068 void    free_old_images(void);
00069 
00070 /* ********************************** NEW IMAGE API *********************** */
00071 
00072 /* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */
00073 /* should be used in conjunction with an ID * to Image. */
00074 struct ImageUser;
00075 struct RenderPass;
00076 struct RenderResult;
00077 
00078 /* ima->source; where image comes from */
00079 #define IMA_SRC_CHECK           0
00080 #define IMA_SRC_FILE            1
00081 #define IMA_SRC_SEQUENCE        2
00082 #define IMA_SRC_MOVIE           3
00083 #define IMA_SRC_GENERATED       4
00084 #define IMA_SRC_VIEWER          5
00085 
00086 /* ima->type, how to handle/generate it */
00087 #define IMA_TYPE_IMAGE          0
00088 #define IMA_TYPE_MULTILAYER     1
00089                 /* generated */
00090 #define IMA_TYPE_UV_TEST        2
00091                 /* viewers */
00092 #define IMA_TYPE_R_RESULT   4
00093 #define IMA_TYPE_COMPOSITE      5
00094 
00095 /* ima->ok */
00096 #define IMA_OK                          1
00097 #define IMA_OK_LOADED           2
00098 
00099 /* signals */
00100         /* reload only frees, doesn't read until image_get_ibuf() called */
00101 #define IMA_SIGNAL_RELOAD                       0
00102 #define IMA_SIGNAL_FREE                         1
00103         /* source changes, from image to sequence or movie, etc */
00104 #define IMA_SIGNAL_SRC_CHANGE           5
00105         /* image-user gets a new image, check settings */
00106 #define IMA_SIGNAL_USER_NEW_IMAGE       6
00107 
00108 /* depending Image type, and (optional) ImageUser setting it returns ibuf */
00109 /* always call to make signals work */
00110 struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
00111 
00112 /* same as above, but can be used to retrieve images being rendered in
00113  * a thread safe way, always call both acquire and release */
00114 struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r);
00115 void BKE_image_release_ibuf(struct Image *ima, void *lock);
00116 
00117 /* returns existing Image when filename/type is same (frame optional) */
00118 struct Image *BKE_add_image_file(const char *name);
00119 
00120 /* adds image, adds ibuf, generates color or pattern */
00121 struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]);
00122 /* adds image from imbuf, owns imbuf */
00123 struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf);
00124 
00125 /* for reload, refresh, pack */
00126 void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);
00127 
00128 /* ensures an Image exists for viewing nodes or render */
00129 struct Image *BKE_image_verify_viewer(int type, const char *name);
00130 
00131 /* force an ImBuf to become part of Image */
00132 void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf);
00133 
00134 /* called on frame change or before render */
00135 void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr);
00136 int BKE_image_user_get_frame(const struct ImageUser *iuser, int cfra, int fieldnr);
00137 
00138 /* fix things in ImageUser when new image gets assigned */
00139 void BKE_image_user_new_image(struct Image *ima, struct ImageUser *iuser);
00140 
00141 /* sets index offset for multilayer files */
00142 struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser);
00143 
00144 /* for multilayer images as well as for render-viewer */
00145 struct RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima);
00146 void BKE_image_release_renderresult(struct Scene *scene, struct Image *ima);
00147 
00148 /* for multiple slot render, call this before render */
00149 void BKE_image_backup_render(struct Scene *scene, struct Image *ima);
00150         
00151 /* goes over all textures that use images */
00152 void    BKE_image_free_all_textures(void);
00153 
00154 /* does one image! */
00155 void    BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
00156 
00157 /* does all images with type MOVIE or SEQUENCE */
00158 void BKE_image_all_free_anim_ibufs(int except_frame);
00159 
00160 void BKE_image_memorypack(struct Image *ima);
00161 
00162 /* prints memory statistics for images */
00163 void BKE_image_print_memlist(void);
00164 
00165 /* empty image block, of similar type and filename */
00166 struct Image *copy_image(struct Image *ima);
00167 
00168 /* merge source into dest, and free source */
00169 void BKE_image_merge(struct Image *dest, struct Image *source);
00170 
00171 /* image_gen.c */
00172 void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4]);
00173 void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int height, int width);
00174 void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int height, int width);
00175 
00176 #ifdef __cplusplus
00177 }
00178 #endif
00179 
00180 #endif
00181