2011-02-18 13:05:18 +00:00
|
|
|
/*
|
2002-10-12 11:37:38 +00:00
|
|
|
* $Id$
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
#ifndef BKE_IMAGE_H
|
|
|
|
#define BKE_IMAGE_H
|
|
|
|
|
2011-02-18 13:05:18 +00:00
|
|
|
/** \file BKE_image.h
|
|
|
|
* \ingroup bke
|
|
|
|
* \since March 2001
|
|
|
|
* \author nzc
|
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct Image;
|
|
|
|
struct ImBuf;
|
|
|
|
struct Tex;
|
|
|
|
struct anim;
|
2009-01-04 14:14:06 +00:00
|
|
|
struct Scene;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* call from library */
|
|
|
|
void free_image(struct Image *me);
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
void BKE_stamp_info(struct Scene *scene, struct ImBuf *ibuf);
|
|
|
|
void BKE_stamp_buf(struct Scene *scene, unsigned char *rect, float *rectf, int width, int height, int channels);
|
2010-11-30 23:38:31 +00:00
|
|
|
int BKE_alphatest_ibuf(struct ImBuf *ibuf);
|
2010-11-17 09:45:45 +00:00
|
|
|
int BKE_write_ibuf(struct Scene *scene, struct ImBuf *ibuf, const char *name, int imtype, int subimtype, int quality);
|
2010-11-16 14:40:46 +00:00
|
|
|
void BKE_makepicstring(char *string, const char *base, int frame, int imtype, const short use_ext, const short use_frames);
|
2010-09-17 05:58:06 +00:00
|
|
|
int BKE_add_image_extension(char *string, int imtype);
|
2006-12-20 17:57:56 +00:00
|
|
|
int BKE_ftype_to_imtype(int ftype);
|
|
|
|
int BKE_imtype_to_ftype(int imtype);
|
|
|
|
int BKE_imtype_is_movie(int imtype);
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
struct anim *openanim(char * name, int flags);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
void image_de_interlace(struct Image *ima, int odd);
|
2006-07-05 17:32:49 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
void tag_image_time(struct Image *ima);
|
|
|
|
void free_old_images(void);
|
|
|
|
|
|
|
|
/* ********************************** NEW IMAGE API *********************** */
|
|
|
|
|
|
|
|
/* ImageUser is in Texture, in Nodes, Background Image, Image Window, .... */
|
|
|
|
/* should be used in conjunction with an ID * to Image. */
|
|
|
|
struct ImageUser;
|
|
|
|
struct RenderPass;
|
|
|
|
struct RenderResult;
|
|
|
|
|
|
|
|
/* ima->source; where image comes from */
|
|
|
|
#define IMA_SRC_CHECK 0
|
|
|
|
#define IMA_SRC_FILE 1
|
|
|
|
#define IMA_SRC_SEQUENCE 2
|
|
|
|
#define IMA_SRC_MOVIE 3
|
|
|
|
#define IMA_SRC_GENERATED 4
|
|
|
|
#define IMA_SRC_VIEWER 5
|
|
|
|
|
|
|
|
/* ima->type, how to handle/generate it */
|
|
|
|
#define IMA_TYPE_IMAGE 0
|
|
|
|
#define IMA_TYPE_MULTILAYER 1
|
|
|
|
/* generated */
|
|
|
|
#define IMA_TYPE_UV_TEST 2
|
|
|
|
/* viewers */
|
|
|
|
#define IMA_TYPE_R_RESULT 4
|
|
|
|
#define IMA_TYPE_COMPOSITE 5
|
|
|
|
|
|
|
|
/* ima->ok */
|
|
|
|
#define IMA_OK 1
|
|
|
|
#define IMA_OK_LOADED 2
|
|
|
|
|
|
|
|
/* signals */
|
|
|
|
/* reload only frees, doesn't read until image_get_ibuf() called */
|
|
|
|
#define IMA_SIGNAL_RELOAD 0
|
|
|
|
#define IMA_SIGNAL_FREE 1
|
|
|
|
/* source changes, from image to sequence or movie, etc */
|
|
|
|
#define IMA_SIGNAL_SRC_CHANGE 5
|
|
|
|
/* image-user gets a new image, check settings */
|
|
|
|
#define IMA_SIGNAL_USER_NEW_IMAGE 6
|
|
|
|
|
|
|
|
/* depending Image type, and (optional) ImageUser setting it returns ibuf */
|
|
|
|
/* always call to make signals work */
|
|
|
|
struct ImBuf *BKE_image_get_ibuf(struct Image *ima, struct ImageUser *iuser);
|
|
|
|
|
2009-09-30 18:18:32 +00:00
|
|
|
/* same as above, but can be used to retrieve images being rendered in
|
|
|
|
* a thread safe way, always call both acquire and release */
|
|
|
|
struct ImBuf *BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **lock_r);
|
|
|
|
void BKE_image_release_ibuf(struct Image *ima, void *lock);
|
|
|
|
|
2009-01-04 14:14:06 +00:00
|
|
|
/* returns existing Image when filename/type is same (frame optional) */
|
2010-10-15 12:29:02 +00:00
|
|
|
struct Image *BKE_add_image_file(const char *name);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* adds image, adds ibuf, generates color or pattern */
|
2010-11-17 09:45:45 +00:00
|
|
|
struct Image *BKE_add_image_size(unsigned int width, unsigned int height, const char *name, int depth, int floatbuf, short uvtestgrid, float color[4]);
|
2010-03-08 20:08:04 +00:00
|
|
|
/* adds image from imbuf, owns imbuf */
|
|
|
|
struct Image *BKE_add_image_imbuf(struct ImBuf *ibuf);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* for reload, refresh, pack */
|
|
|
|
void BKE_image_signal(struct Image *ima, struct ImageUser *iuser, int signal);
|
|
|
|
|
|
|
|
/* ensures an Image exists for viewing nodes or render */
|
|
|
|
struct Image *BKE_image_verify_viewer(int type, const char *name);
|
|
|
|
|
|
|
|
/* force an ImBuf to become part of Image */
|
|
|
|
void BKE_image_assign_ibuf(struct Image *ima, struct ImBuf *ibuf);
|
|
|
|
|
|
|
|
/* called on frame change or before render */
|
2010-01-19 14:04:33 +00:00
|
|
|
void BKE_image_user_calc_frame(struct ImageUser *iuser, int cfra, int fieldnr);
|
2006-12-20 17:57:56 +00:00
|
|
|
|
|
|
|
/* fix things in ImageUser when new image gets assigned */
|
|
|
|
void BKE_image_user_new_image(struct Image *ima, struct ImageUser *iuser);
|
|
|
|
|
|
|
|
/* sets index offset for multilayer files */
|
|
|
|
struct RenderPass *BKE_image_multilayer_index(struct RenderResult *rr, struct ImageUser *iuser);
|
|
|
|
|
|
|
|
/* for multilayer images as well as for render-viewer */
|
2009-09-30 18:18:32 +00:00
|
|
|
struct RenderResult *BKE_image_acquire_renderresult(struct Scene *scene, struct Image *ima);
|
|
|
|
void BKE_image_release_renderresult(struct Scene *scene, struct Image *ima);
|
2010-03-27 15:35:34 +00:00
|
|
|
|
|
|
|
/* for multiple slot render, call this before render */
|
|
|
|
void BKE_image_backup_render(struct Scene *scene, struct Image *ima);
|
2010-01-09 00:16:35 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
/* goes over all textures that use images */
|
|
|
|
void BKE_image_free_all_textures(void);
|
|
|
|
|
|
|
|
/* does one image! */
|
|
|
|
void BKE_image_free_anim_ibufs(struct Image *ima, int except_frame);
|
|
|
|
|
|
|
|
/* does all images with type MOVIE or SEQUENCE */
|
|
|
|
void BKE_image_all_free_anim_ibufs(int except_frame);
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2006-12-20 17:57:56 +00:00
|
|
|
void BKE_image_memorypack(struct Image *ima);
|
3D view orbit option: Around Active
This fixes the active object in place when orbiting the view.
Choppy 15fps demo can be seen there: http://www.elysiun.com/~theeth/bf/around_active.html
Image Memory Grabage Collection
This adds memory handling to the image code. An image is tagged each time it is used.
During a collection cycle (frequency of cycles is user defined), if an image is older
than a user defined limit, its buffer gets deallocated. This also applies to gl memory buffers.
Images that are loading in GL memory needs to go through two time outs before being fully deallocated: the first time out deallocated the gl memorry, the second the buffer in ram.
Notes:
Image buffer loaded from python gets tagged as permanent upon load. That tag is removed when python stops using the image.
I might have missed some tagging spots, especially in the rendering pipeline. Someone with more knowledge about this code should check to be careful.
Tagging is done on every access, for rendering, this will probably be a performance hit. A scheme should be developped to only tag when the rendering is completed.
Collecting is called in draw_object, most likely not the best place to do it.
Safe from undo, since using undo deallocates memory anyway (like when loading a blend file with one currently opened)
Userpref DNA changes:
I've changed a couple of flagging variables from short to int. Some because they needed more space, others to keep SDNA happy.
Info window changes:
I've grouped a couple of buttons in aligned blocks and changed the color of mutually exclusive options to make them clearer.
Matt didn't do any changes on that in tuhopuu, so hopefully I'm not stepping on anyone's feet with this.
Also changed double constants into floats with f in a couple of places (mostly space.c) to make compiler happier.
2005-07-06 00:33:41 +00:00
|
|
|
|
2008-02-01 12:14:15 +00:00
|
|
|
/* prints memory statistics for images */
|
|
|
|
void BKE_image_print_memlist(void);
|
|
|
|
|
2009-01-27 19:32:44 +00:00
|
|
|
/* empty image block, of similar type and filename */
|
2010-07-30 06:09:23 +00:00
|
|
|
struct Image *copy_image(struct Image *ima);
|
2009-01-27 19:32:44 +00:00
|
|
|
|
|
|
|
/* merge source into dest, and free source */
|
|
|
|
void BKE_image_merge(struct Image *dest, struct Image *source);
|
|
|
|
|
2010-03-21 00:25:52 +00:00
|
|
|
/* image_gen.c */
|
|
|
|
void BKE_image_buf_fill_color(unsigned char *rect, float *rect_float, int width, int height, float color[4]);
|
|
|
|
void BKE_image_buf_fill_checker(unsigned char *rect, float *rect_float, int height, int width);
|
|
|
|
void BKE_image_buf_fill_checker_color(unsigned char *rect, float *rect_float, int height, int width);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2002-10-30 02:07:20 +00:00
|
|
|
|