2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): none yet.
25 * ***** END GPL LICENSE BLOCK *****
28 #ifndef __IMB_IMBUF_TYPES_H__
29 #define __IMB_IMBUF_TYPES_H__
32 * \file IMB_imbuf_types.h
34 * \brief Contains defines and structs used throughout the imbuf module.
35 * \todo Clean up includes.
37 * Types needed for using the image buffer.
39 * Imbuf is external code, slightly adapted to live in the Blender
40 * context. It requires an external jpeg module, and the avi-module
41 * (also external code) in order to function correctly.
43 * This file contains types and some constants that go with them. Most
44 * are self-explanatory (e.g. IS_amiga tests whether the buffer
45 * contains an Amiga-format file).
50 #define IB_MIPMAP_LEVELS 20
51 #define IB_FILENAME_SIZE 1024
53 typedef struct DDSData {
54 unsigned int fourcc; /* DDS fourcc info */
55 unsigned int nummipmaps; /* The number of mipmaps in the dds file */
56 unsigned char *data; /* The compressed image data */
57 unsigned int size; /* The size of the compressed data */
62 * This is the abstraction of an image. ImBuf is the basic type used for all
65 * Also; add new variables to the end to save pain!
68 typedef struct ImBuf {
69 struct ImBuf *next, *prev; /**< allow lists of ImBufs, for caches or flipbooks */
72 int x, y; /* width and Height of our image buffer.
73 * Should be 'unsigned int' since most formats use this.
74 * but this is problematic with texture math in imagetexture.c
75 * avoid problems and use int. - campbell */
77 unsigned char planes; /* Active amount of bits/bitplanes */
78 int channels; /* amount of channels in rect_float (0 = 4 channel default) */
81 int flags; /* Controls which components should exist. */
82 int mall; /* what is malloced internal, and can be freed */
85 unsigned int *rect; /* pixel values stored here */
86 float *rect_float; /* floating point Rect equivalent
87 * Linear RGB color space - may need gamma correction to
88 * sRGB when generating 8bit representations */
90 /* resolution - pixels per meter */
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 */
106 struct ImBuf *mipmap[IB_MIPMAP_LEVELS]; /* MipMap levels, a series of halved images */
107 int miptot, miplevel;
109 /* externally used data */
110 int index; /* reference index for ImBuf lists */
111 int userflags; /* used to set imbuf to dirty and other stuff */
112 struct ImMetaData *metadata; /* image metadata */
113 void *userdata; /* temporary storage, only used by baking at the moment */
115 /* file information */
116 int ftype; /* file type we are going to save as */
117 char name[IB_FILENAME_SIZE]; /* filename associated with this image */
118 char cachename[IB_FILENAME_SIZE]; /* full filename used for reading from cache */
120 /* memory cache limiter */
121 struct MEM_CacheLimiterHandle_s *c_handle; /* handle for cache limiter */
122 int refcounter; /* reference counter for multiple users */
124 /* some parameters to pass along for packing images */
125 unsigned char *encodedbuffer; /* Compressed image only used with png currently */
126 unsigned int encodedsize; /* Size of data written to encodedbuffer */
127 unsigned int encodedbuffersize; /* Size of encodedbuffer */
129 /* color management */
130 struct ColorSpace *rect_colorspace; /* color space of byte buffer */
131 struct ColorSpace *float_colorspace; /* color space of float buffer, used by sequencer only */
132 unsigned int *display_buffer_flags; /* array of per-display display buffers dirty flags */
133 struct ColormanageCache *colormanage_cache; /* cache used by color management */
134 int colormanage_flag;
136 /* information for compressed textures */
137 struct DDSData dds_data;
140 /* Moved from BKE_bmfont_types.h because it is a userflag bit mask. */
142 * \brief userflags: Flags used internally by blender for imagebuffers
145 #define IB_BITMAPFONT (1 << 0) /* this image is a font */
146 #define IB_BITMAPDIRTY (1 << 1) /* image needs to be saved is not the same as filename */
147 #define IB_MIPMAP_INVALID (1 << 2) /* image mipmaps are invalid, need recreate */
148 #define IB_RECT_INVALID (1 << 3) /* float buffer changed, needs recreation of byte rect */
149 #define IB_DISPLAY_BUFFER_INVALID (1 << 4) /* either float or byte buffer changed, need to re-calculate display buffers */
152 * \name Imbuf Component flags
153 * \brief These flags determine the components of an ImBuf struct.
156 /** \brief Flag defining the components of the ImBuf struct. */
158 #define IB_rect (1 << 0)
159 #define IB_test (1 << 1)
160 #define IB_fields (1 << 2)
161 #define IB_zbuf (1 << 3)
162 #define IB_mem (1 << 4)
163 #define IB_rectfloat (1 << 5)
164 #define IB_zbuffloat (1 << 6)
165 #define IB_multilayer (1 << 7)
166 #define IB_metadata (1 << 8)
167 #define IB_animdeinterlace (1 << 9)
168 #define IB_tiles (1 << 10)
169 #define IB_tilecache (1 << 11)
170 #define IB_alphamode_premul (1 << 12) /* indicates whether image on disk have premul alpha */
171 #define IB_alphamode_detect (1 << 13) /* if this flag is set, alpha mode would be guessed from file */
172 #define IB_ignore_alpha (1 << 14) /* ignore alpha on load and substitude it with 1.0f */
175 * The bit flag is stored in the ImBuf.ftype variable.
176 * Note that the lower 11 bits is used for storing custom flags
178 #define IB_CUSTOM_FLAGS_MASK 0x400
180 #define PNG (1 << 30)
181 #define TGA (1 << 28)
182 #define JPG (1 << 27)
183 #define BMP (1 << 26)
185 #ifdef WITH_QUICKTIME
186 #define QUICKTIME (1 << 25)
190 #define RADHDR (1 << 24)
193 #define TIF (1 << 23)
194 #define TIF_16BIT (1 << 8 )
197 #define OPENEXR (1 << 22)
198 #define OPENEXR_HALF (1 << 8 )
199 #define OPENEXR_COMPRESS (7)
202 #define CINEON (1 << 21)
203 #define DPX (1 << 20)
204 #define CINEON_LOG (1 << 8)
205 #define CINEON_16BIT (1 << 7)
206 #define CINEON_12BIT (1 << 6)
207 #define CINEON_10BIT (1 << 5)
211 #define DDS (1 << 19)
215 #define JP2 (1 << 18)
216 #define JP2_12BIT (1 << 17)
217 #define JP2_16BIT (1 << 16)
218 #define JP2_YCC (1 << 15)
219 #define JP2_CINE (1 << 14)
220 #define JP2_CINE_48FPS (1 << 13)
221 #define JP2_JP2 (1 << 12)
222 #define JP2_J2K (1 << 11)
225 #define PNG_16BIT (1 << 10)
227 #define RAWTGA (TGA | 1)
229 #define JPG_STD (JPG | (0 << 8))
230 #define JPG_VID (JPG | (1 << 8))
231 #define JPG_JST (JPG | (2 << 8))
232 #define JPG_MAX (JPG | (3 << 8))
233 #define JPG_MSK (0xffffff00)
238 * \name Imbuf preset profile tags
239 * \brief Some predefined color space profiles that 8 bit imbufs can represent
241 #define IB_PROFILE_NONE 0
242 #define IB_PROFILE_LINEAR_RGB 1
243 #define IB_PROFILE_SRGB 2
244 #define IB_PROFILE_CUSTOM 3
249 #define MAKEFOURCC(ch0, ch1, ch2, ch3)\
250 ((unsigned long)(unsigned char)(ch0) | \
251 ((unsigned long)(unsigned char)(ch1) << 8) | \
252 ((unsigned long)(unsigned char)(ch2) << 16) | \
253 ((unsigned long)(unsigned char)(ch3) << 24))
254 #endif /* MAKEFOURCC */
257 * FOURCC codes for DX compressed-texture pixel formats
260 #define FOURCC_DDS (MAKEFOURCC('D','D','S',' '))
261 #define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1'))
262 #define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2'))
263 #define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3'))
264 #define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4'))
265 #define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5'))
268 extern const char *imb_ext_image[];
269 extern const char *imb_ext_image_qt[];
270 extern const char *imb_ext_movie[];
271 extern const char *imb_ext_audio[];
274 IMB_COLORMANAGE_IS_DATA = (1 << 0)