Blender  V2.93
IMB_imbuf_types.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
20 #pragma once
21 
22 #include "DNA_vec_types.h" /* for rcti */
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
44 #define IMB_MIPMAP_LEVELS 20
45 #define IMB_FILENAME_SIZE 1024
46 
47 typedef struct DDSData {
49  unsigned int fourcc;
51  unsigned int nummipmaps;
53  unsigned char *data;
55  unsigned int size;
57 
66 /* Warning: Keep explicit value assignments here,
67  * this file is included in areas where not all format defines are set
68  * (e.g. intern/dds only get WITH_DDS, even if TIFF, HDR etc are also defined).
69  * See T46524. */
70 
79 #ifdef WITH_OPENIMAGEIO
80  IMB_FTYPE_PSD = 7,
81 #endif
82 #ifdef WITH_OPENJPEG
83  IMB_FTYPE_JP2 = 8,
84 #endif
85 #ifdef WITH_HDR
86  IMB_FTYPE_RADHDR = 9,
87 #endif
88 #ifdef WITH_TIFF
89  IMB_FTYPE_TIF = 10,
90 #endif
91 #ifdef WITH_CINEON
92  IMB_FTYPE_CINEON = 11,
93  IMB_FTYPE_DPX = 12,
94 #endif
95 
96 #ifdef WITH_DDS
97  IMB_FTYPE_DDS = 13,
98 #endif
99 };
100 
101 /* Only for readability. */
102 #define IMB_FTYPE_NONE 0
103 
104 /* ibuf->foptions flag, type specific options.
105  * Some formats include compression rations on some bits */
106 
107 #define OPENEXR_HALF (1 << 8)
108 /* careful changing this, it's used in DNA as well */
109 #define OPENEXR_COMPRESS (15)
110 
111 #ifdef WITH_CINEON
112 # define CINEON_LOG (1 << 8)
113 # define CINEON_16BIT (1 << 7)
114 # define CINEON_12BIT (1 << 6)
115 # define CINEON_10BIT (1 << 5)
116 #endif
117 
118 #ifdef WITH_OPENJPEG
119 # define JP2_12BIT (1 << 9)
120 # define JP2_16BIT (1 << 8)
121 # define JP2_YCC (1 << 7)
122 # define JP2_CINE (1 << 6)
123 # define JP2_CINE_48FPS (1 << 5)
124 # define JP2_JP2 (1 << 4)
125 # define JP2_J2K (1 << 3)
126 #endif
127 
128 #define PNG_16BIT (1 << 10)
129 
130 #define RAWTGA 1
131 
132 #ifdef WITH_TIFF
133 # define TIF_16BIT (1 << 8)
134 # define TIF_COMPRESS_NONE (1 << 7)
135 # define TIF_COMPRESS_DEFLATE (1 << 6)
136 # define TIF_COMPRESS_LZW (1 << 5)
137 # define TIF_COMPRESS_PACKBITS (1 << 4)
138 #endif
139 
140 typedef struct ImbFormatOptions {
141  short flag;
143  char quality;
145 
152 typedef enum eImBufFlags {
153  IB_rect = 1 << 0,
154  IB_test = 1 << 1,
155  IB_zbuf = 1 << 3,
156  IB_mem = 1 << 4,
157  IB_rectfloat = 1 << 5,
158  IB_zbuffloat = 1 << 6,
159  IB_multilayer = 1 << 7,
160  IB_metadata = 1 << 8,
162  IB_tiles = 1 << 10,
163  IB_tilecache = 1 << 11,
168  /* alpha channel is unrelated to RGB and should not affect it */
172  IB_thumbnail = 1 << 16,
173  IB_multiview = 1 << 17,
174  IB_halffloat = 1 << 18,
176 
178 typedef struct ImBuf {
179  struct ImBuf *next, *prev;
181  /* dimensions */
186  int x, y;
187 
189  unsigned char planes;
191  int channels;
192 
193  /* flags */
195  int flags;
197  int mall;
198 
199  /* pixels */
200 
205  unsigned int *rect;
212  float *rect_float;
213 
215  double ppm[2];
216 
217  /* tiled pixel storage */
218  int tilex, tiley;
220  unsigned int **tiles;
221 
222  /* zbuffer */
224  int *zbuf;
226  float *zbuf_float;
227 
228  /* parameters used by conversion between byte and float */
230  float dither;
231 
232  /* mipmapping */
236 
237  /* externally used data */
239  int index;
245  void *userdata;
246 
247  /* file information */
249  enum eImbFileType ftype;
256 
257  /* memory cache limiter */
259  struct MEM_CacheLimiterHandle_s *c_handle;
262 
263  /* some parameters to pass along for packing images */
265  unsigned char *encodedbuffer;
267  unsigned int encodedsize;
269  unsigned int encodedbuffersize;
270 
271  /* color management */
277  unsigned int *display_buffer_flags;
282 
283  /* information for compressed textures */
284  struct DDSData dds_data;
286 
291 enum {
293  IB_BITMAPDIRTY = (1 << 1),
295  IB_MIPMAP_INVALID = (1 << 2),
297  IB_RECT_INVALID = (1 << 3),
301  IB_PERSISTENT = (1 << 5),
302 };
303 
309 #define IB_PROFILE_NONE 0
310 #define IB_PROFILE_LINEAR_RGB 1
311 #define IB_PROFILE_SRGB 2
312 #define IB_PROFILE_CUSTOM 3
313 
316 /* dds */
317 #ifdef WITH_DDS
318 # ifndef DDS_MAKEFOURCC
319 # define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
320  ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
321  ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
322 # endif /* DDS_MAKEFOURCC */
323 
324 /*
325  * FOURCC codes for DX compressed-texture pixel formats
326  */
327 
328 # define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
329 # define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
330 # define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
331 # define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
332 # define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
333 # define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
334 
335 #endif /* DDS */
336 extern const char *imb_ext_image[];
337 extern const char *imb_ext_movie[];
338 extern const char *imb_ext_audio[];
339 
340 /* image formats that can only be loaded via filepath */
341 extern const char *imb_ext_image_filepath_only[];
342 
349 enum {
351 };
352 
355 #ifdef __cplusplus
356 }
357 #endif
@ IB_PERSISTENT
@ IB_RECT_INVALID
@ IB_BITMAPDIRTY
@ IB_MIPMAP_INVALID
@ IB_DISPLAY_BUFFER_INVALID
struct DDSData DDSData
const char * imb_ext_image_filepath_only[]
Definition: util.c:86
struct ImbFormatOptions ImbFormatOptions
@ IMB_COLORMANAGE_IS_DATA
const char * imb_ext_movie[]
Definition: util.c:95
#define IMB_FILENAME_SIZE
#define IMB_MIPMAP_LEVELS
const char * imb_ext_audio[]
Definition: util.c:102
struct ImBuf ImBuf
eImBufFlags
@ IB_zbuf
@ IB_animdeinterlace
@ IB_alphamode_channel_packed
@ IB_halffloat
@ IB_alphamode_premul
@ IB_alphamode_ignore
@ IB_rectfloat
@ IB_metadata
@ IB_multilayer
@ IB_tiles
@ IB_tilecache
@ IB_alphamode_detect
@ IB_zbuffloat
@ IB_thumbnail
@ IB_multiview
@ IB_mem
@ IB_test
@ IB_rect
const char * imb_ext_image[]
Definition: util.c:60
eImbFileType
@ IMB_FTYPE_BMP
@ IMB_FTYPE_IMAGIC
@ IMB_FTYPE_JPG
@ IMB_FTYPE_TGA
@ IMB_FTYPE_OPENEXR
@ IMB_FTYPE_PNG
unsigned int size
unsigned int nummipmaps
unsigned char * data
unsigned int fourcc
struct DDSData dds_data
struct IDProperty * metadata
void * userdata
struct MEM_CacheLimiterHandle_s * c_handle
struct ImBuf * mipmap[IMB_MIPMAP_LEVELS]
unsigned int ** tiles
struct ImBuf * prev
rcti invalid_rect
float * zbuf_float
int channels
int userflags
struct ColorSpace * rect_colorspace
struct ImBuf * next
ImbFormatOptions foptions
unsigned char * encodedbuffer
float dither
unsigned int encodedbuffersize
int colormanage_flag
unsigned char planes
char name[IMB_FILENAME_SIZE]
enum eImbFileType ftype
unsigned int * rect
unsigned int encodedsize
char cachename[IMB_FILENAME_SIZE]
int miplevel
float * rect_float
struct ColorSpace * float_colorspace
unsigned int * display_buffer_flags
int * zbuf
double ppm[2]
struct ColormanageCache * colormanage_cache
int refcounter