2 * IMB_imbuf_types.h (mar-2001 nzc)
4 * Types needed for using the image buffer.
6 * Imbuf is external code, slightly adapted to live in the Blender
7 * context. It requires an external jpeg module, and the avi-module
8 * (also external code) in order to function correctly.
10 * This file contains types and some constants that go with them. Most
11 * are self-explanatory (e.g. IS_amiga tests whether the buffer
12 * contains an Amiga-format file).
16 * ***** BEGIN GPL LICENSE BLOCK *****
18 * This program is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU General Public License
20 * as published by the Free Software Foundation; either version 2
21 * of the License, or (at your option) any later version.
23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software Foundation,
30 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
32 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
33 * All rights reserved.
35 * The Original Code is: all of this file.
37 * Contributor(s): none yet.
39 * ***** END GPL LICENSE BLOCK *****
42 * \file IMB_imbuf_types.h
44 * \brief Contains defines and structs used throughout the imbuf module.
45 * \todo Clean up includes.
48 #ifndef IMB_IMBUF_TYPES_H
49 #define IMB_IMBUF_TYPES_H
53 #define IB_MIPMAP_LEVELS 20
54 #define IB_FILENAME_SIZE 1023
57 * \brief The basic imbuf type
59 * This is the abstraction of an image. ImBuf is the basic type used for all
62 * REMINDER: if any changes take place, they need to be carried over
63 * to source/blender/blenpluginapi/iff.h too, OTHERWISE PLUGINS WON'T
66 * Also; add new variables to the end to save pain!
68 * Also, that iff.h needs to be in the final release "plugins/include" dir, too!
70 typedef struct ImBuf {
71 struct ImBuf *next, *prev; /**< allow lists of ImBufs, for caches or flipbooks */
74 int x, y; /* width and Height of our image buffer.
75 * Should be 'unsigned int' since most formats use this.
76 * but this is problematic with texture math in imagetexture.c
77 * avoid problems and use int. - campbell */
79 unsigned char depth; /* Active amount of bits/bitplanes */
80 int channels; /* amount of channels in rect_float (0 = 4 channel default) */
83 int flags; /* Controls which components should exist. */
84 int mall; /* what is malloced internal, and can be freed */
87 unsigned int *rect; /* pixel values stored here */
88 unsigned int *crect; /* color corrected pixel values stored here */
89 float *rect_float; /* floating point Rect equivalent
90 Linear RGB color space - may need gamma correction to
91 sRGB when generating 8bit representations */
93 /* tiled pixel storage */
99 int *zbuf; /* z buffer data, original zbuffer */
100 float *zbuf_float; /* z buffer data, camera coordinates */
102 /* parameters used by conversion between byte and float */
103 float dither; /* random dither value, for conversion from float -> byte rect */
104 short profile; /* color space/profile preset that the byte rect buffer represents */
105 char profile_filename[256]; /* to be implemented properly, specific filename for custom profiles */
108 struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */
109 int miptot, miplevel;
111 /* externally used data */
112 int index; /* reference index for ImBuf lists */
113 int userflags; /* used to set imbuf to dirty and other stuff */
114 struct ImMetaData *metadata; /* image metadata */
115 void *userdata; /* temporary storage, only used by baking at the moment */
117 /* file information */
118 int ftype; /* file type we are going to save as */
119 char name[IB_FILENAME_SIZE]; /* filename associated with this image */
120 char cachename[IB_FILENAME_SIZE]; /* full filename used for reading from cache */
122 /* memory cache limiter */
123 struct MEM_CacheLimiterHandle_s *c_handle; /* handle for cache limiter */
124 int refcounter; /* reference counter for multiple users */
126 /* some parameters to pass along for packing images */
127 unsigned char *encodedbuffer; /* Compressed image only used with png currently */
128 unsigned int encodedsize; /* Size of data written to encodedbuffer */
129 unsigned int encodedbuffersize; /* Size of encodedbuffer */
132 /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */
134 * \brief userflags: Flags used internally by blender for imagebuffers
137 #define IB_BITMAPFONT (1 << 0) /* this image is a font */
138 #define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */
139 #define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */
140 #define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */
143 * \name Imbuf Component flags
144 * \brief These flags determine the components of an ImBuf struct.
147 /** \brief Flag defining the components of the ImBuf struct. */
149 #define IB_rect (1 << 0)
150 #define IB_test (1 << 1)
151 #define IB_fields (1 << 2)
152 #define IB_zbuf (1 << 3)
153 #define IB_mem (1 << 4)
154 #define IB_rectfloat (1 << 5)
155 #define IB_zbuffloat (1 << 6)
156 #define IB_multilayer (1 << 7)
157 #define IB_metadata (1 << 8)
158 #define IB_animdeinterlace (1 << 9)
159 #define IB_tiles (1 << 10)
160 #define IB_tilecache (1 << 11)
161 #define IB_premul (1 << 12)
164 * The bit flag is stored in the ImBuf.ftype variable.
165 * Note that the lower 10 bits is used for storing custom flags
167 #define PNG (1 << 30)
168 #define TGA (1 << 28)
169 #define JPG (1 << 27)
170 #define BMP (1 << 26)
172 #ifdef WITH_QUICKTIME
173 #define QUICKTIME (1 << 25)
177 #define RADHDR (1 << 24)
180 #define TIF (1 << 23)
181 #define TIF_16BIT (1 << 8 )
184 #define OPENEXR (1 << 22)
185 #define OPENEXR_HALF (1 << 8 )
186 #define OPENEXR_COMPRESS (7)
189 #define CINEON (1 << 21)
190 #define DPX (1 << 20)
194 #define DDS (1 << 19)
198 #define JP2 (1 << 18)
199 #define JP2_12BIT (1 << 17)
200 #define JP2_16BIT (1 << 16)
201 #define JP2_YCC (1 << 15)
202 #define JP2_CINE (1 << 14)
203 #define JP2_CINE_48FPS (1 << 13)
206 #define RAWTGA (TGA | 1)
208 #define JPG_STD (JPG | (0 << 8))
209 #define JPG_VID (JPG | (1 << 8))
210 #define JPG_JST (JPG | (2 << 8))
211 #define JPG_MAX (JPG | (3 << 8))
212 #define JPG_MSK (0xffffff00)
217 * \name Imbuf preset profile tags
218 * \brief Some predefined color space profiles that 8 bit imbufs can represent
220 #define IB_PROFILE_NONE 0
221 #define IB_PROFILE_LINEAR_RGB 1
222 #define IB_PROFILE_SRGB 2
223 #define IB_PROFILE_CUSTOM 3
225 extern const char *imb_ext_image[];
226 extern const char *imb_ext_image_qt[];
227 extern const char *imb_ext_movie[];
228 extern const char *imb_ext_audio[];