Blender  V3.3
IMB_imbuf_types.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
4 #pragma once
5 
6 #include "DNA_vec_types.h" /* for rcti */
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
28 #define IMB_MIPMAP_LEVELS 20
29 #define IMB_FILENAME_SIZE 1024
30 
31 typedef struct DDSData {
33  unsigned int fourcc;
35  unsigned int nummipmaps;
37  unsigned char *data;
39  unsigned int size;
41 
49 /* WARNING: Keep explicit value assignments here,
50  * this file is included in areas where not all format defines are set
51  * (e.g. intern/dds only get WITH_DDS, even if TIFF, HDR etc are also defined).
52  * See T46524. */
53 
62 #ifdef WITH_OPENIMAGEIO
63  IMB_FTYPE_PSD = 7,
64 #endif
65 #ifdef WITH_OPENJPEG
66  IMB_FTYPE_JP2 = 8,
67 #endif
68 #ifdef WITH_HDR
69  IMB_FTYPE_RADHDR = 9,
70 #endif
71 #ifdef WITH_TIFF
72  IMB_FTYPE_TIF = 10,
73 #endif
74 #ifdef WITH_CINEON
75  IMB_FTYPE_CINEON = 11,
76  IMB_FTYPE_DPX = 12,
77 #endif
78 
79 #ifdef WITH_DDS
80  IMB_FTYPE_DDS = 13,
81 #endif
82 #ifdef WITH_WEBP
83  IMB_FTYPE_WEBP = 14,
84 #endif
85 };
86 
87 /* Only for readability. */
88 #define IMB_FTYPE_NONE 0
89 
90 /* ibuf->foptions flag, type specific options.
91  * Some formats include compression rations on some bits */
92 
93 #define OPENEXR_HALF (1 << 8)
94 /* careful changing this, it's used in DNA as well */
95 #define OPENEXR_COMPRESS (15)
96 
97 #ifdef WITH_CINEON
98 # define CINEON_LOG (1 << 8)
99 # define CINEON_16BIT (1 << 7)
100 # define CINEON_12BIT (1 << 6)
101 # define CINEON_10BIT (1 << 5)
102 #endif
103 
104 #ifdef WITH_OPENJPEG
105 # define JP2_12BIT (1 << 9)
106 # define JP2_16BIT (1 << 8)
107 # define JP2_YCC (1 << 7)
108 # define JP2_CINE (1 << 6)
109 # define JP2_CINE_48FPS (1 << 5)
110 # define JP2_JP2 (1 << 4)
111 # define JP2_J2K (1 << 3)
112 #endif
113 
114 #define PNG_16BIT (1 << 10)
115 
116 #define RAWTGA 1
117 
118 #ifdef WITH_TIFF
119 # define TIF_16BIT (1 << 8)
120 # define TIF_COMPRESS_NONE (1 << 7)
121 # define TIF_COMPRESS_DEFLATE (1 << 6)
122 # define TIF_COMPRESS_LZW (1 << 5)
123 # define TIF_COMPRESS_PACKBITS (1 << 4)
124 #endif
125 
126 typedef struct ImbFormatOptions {
127  short flag;
129  char quality;
131 
132 /* -------------------------------------------------------------------- */
137 typedef enum eImBufFlags {
138  IB_rect = 1 << 0,
139  IB_test = 1 << 1,
140  IB_zbuf = 1 << 3,
141  IB_mem = 1 << 4,
142  IB_rectfloat = 1 << 5,
143  IB_zbuffloat = 1 << 6,
144  IB_multilayer = 1 << 7,
145  IB_metadata = 1 << 8,
147  IB_tiles = 1 << 10,
148  IB_tilecache = 1 << 11,
153  /* alpha channel is unrelated to RGB and should not affect it */
157  IB_thumbnail = 1 << 16,
158  IB_multiview = 1 << 17,
159  IB_halffloat = 1 << 18,
161 
164 /* -------------------------------------------------------------------- */
168 typedef struct ImBuf {
169  struct ImBuf *next, *prev;
171  /* dimensions */
176  int x, y;
177 
179  unsigned char planes;
181  int channels;
182 
183  /* flags */
185  int flags;
187  int mall;
188 
189  /* pixels */
190 
195  unsigned int *rect;
202  float *rect_float;
203 
205  double ppm[2];
206 
207  /* tiled pixel storage */
208  int tilex, tiley;
210  unsigned int **tiles;
211 
212  /* zbuffer */
214  int *zbuf;
216  float *zbuf_float;
217 
218  /* parameters used by conversion between byte and float */
220  float dither;
221 
222  /* mipmapping */
226 
227  /* externally used data */
229  int index;
235  void *userdata;
236 
237  /* file information */
239  enum eImbFileType ftype;
246 
247  /* memory cache limiter */
249  struct MEM_CacheLimiterHandle_s *c_handle;
252 
253  /* some parameters to pass along for packing images */
255  unsigned char *encodedbuffer;
257  unsigned int encodedsize;
259  unsigned int encodedbuffersize;
260 
261  /* color management */
267  unsigned int *display_buffer_flags;
272 
273  /* information for compressed textures */
274  struct DDSData dds_data;
276 
281 enum {
283  IB_BITMAPDIRTY = (1 << 1),
285  IB_MIPMAP_INVALID = (1 << 2),
287  IB_RECT_INVALID = (1 << 3),
291  IB_PERSISTENT = (1 << 5),
292 };
293 
296 /* -------------------------------------------------------------------- */
302 #define IB_PROFILE_NONE 0
303 #define IB_PROFILE_LINEAR_RGB 1
304 #define IB_PROFILE_SRGB 2
305 #define IB_PROFILE_CUSTOM 3
306 
309 /* dds */
310 #ifdef WITH_DDS
311 # ifndef DDS_MAKEFOURCC
312 # define DDS_MAKEFOURCC(ch0, ch1, ch2, ch3) \
313  ((unsigned long)(unsigned char)(ch0) | ((unsigned long)(unsigned char)(ch1) << 8) | \
314  ((unsigned long)(unsigned char)(ch2) << 16) | ((unsigned long)(unsigned char)(ch3) << 24))
315 # endif /* DDS_MAKEFOURCC */
316 
317 /*
318  * FOURCC codes for DX compressed-texture pixel formats.
319  */
320 
321 # define FOURCC_DDS (DDS_MAKEFOURCC('D', 'D', 'S', ' '))
322 # define FOURCC_DXT1 (DDS_MAKEFOURCC('D', 'X', 'T', '1'))
323 # define FOURCC_DXT2 (DDS_MAKEFOURCC('D', 'X', 'T', '2'))
324 # define FOURCC_DXT3 (DDS_MAKEFOURCC('D', 'X', 'T', '3'))
325 # define FOURCC_DXT4 (DDS_MAKEFOURCC('D', 'X', 'T', '4'))
326 # define FOURCC_DXT5 (DDS_MAKEFOURCC('D', 'X', 'T', '5'))
327 
328 #endif /* DDS */
329 extern const char *imb_ext_image[];
330 extern const char *imb_ext_movie[];
331 extern const char *imb_ext_audio[];
332 
334 extern const char *imb_ext_image_filepath_only[];
335 
336 /* -------------------------------------------------------------------- */
342 enum {
344 };
345 
348 #ifdef __cplusplus
349 }
350 #endif
@ IMB_COLORMANAGE_IS_DATA
@ 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:72
struct ImbFormatOptions ImbFormatOptions
const char * imb_ext_movie[]
Definition: util.c:81
#define IMB_FILENAME_SIZE
#define IMB_MIPMAP_LEVELS
const char * imb_ext_audio[]
Definition: util.c:88
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:43
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