Blender V4.5
IMB_colormanagement.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
10
11#include "BLI_compiler_compat.h"
12
14
15#define BCM_CONFIG_FILE "config.ocio"
16
21struct EnumPropertyItem;
22struct ImBuf;
23struct ImageFormatData;
24struct Main;
25struct bContext;
26
27namespace blender::ocio {
28class ColorSpace;
29class Display;
30} // namespace blender::ocio
33
34/* -------------------------------------------------------------------- */
37
39
41 ColorManagedViewSettings *view_settings);
42
45void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name);
46void IMB_colormanagegent_copy_settings(ImBuf *ibuf_src, ImBuf *ibuf_dst);
47void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name);
48void IMB_colormanagement_assign_byte_colorspace(ImBuf *ibuf, const char *name);
49
52const char *IMB_colormanagement_space_from_filepath_rules(const char *filepath);
53
54const ColorSpace *IMB_colormanagement_space_get_named(const char *name);
55bool IMB_colormanagement_space_is_data(const ColorSpace *colorspace);
57bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace);
58bool IMB_colormanagement_space_name_is_data(const char *name);
60bool IMB_colormanagement_space_name_is_srgb(const char *name);
61
63
75BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3]);
79BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3]);
80
84BLI_INLINE void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3]);
85BLI_INLINE void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3]);
87 const float rec709[3]);
89 const float scene_linear[3]);
91 const float aces[3]);
93 const float scene_linear[3]);
96
100void IMB_colormanagement_get_whitepoint(const float temperature,
101 const float tint,
102 float whitepoint[3]);
103bool IMB_colormanagement_set_whitepoint(const float whitepoint[3],
104 float &temperature,
105 float &tint);
106
108
109/* -------------------------------------------------------------------- */
112
116void IMB_colormanagement_transform_float(float *buffer,
117 int width,
118 int height,
119 int channels,
120 const char *from_colorspace,
121 const char *to_colorspace,
122 bool predivide);
126void IMB_colormanagement_transform_byte(unsigned char *buffer,
127 int width,
128 int height,
129 int channels,
130 const char *from_colorspace,
131 const char *to_colorspace);
132
136void IMB_colormanagement_transform_byte_to_float(float *float_buffer,
137 unsigned char *byte_buffer,
138 int width,
139 int height,
140 int channels,
141 const char *from_colorspace,
142 const char *to_colorspace);
143void IMB_colormanagement_transform_v4(float pixel[4],
144 const char *from_colorspace,
145 const char *to_colorspace);
146
153 const ColorSpace *colorspace);
155 bool predivide,
156 const ColorSpace *colorspace);
157
164 const ColorSpace *colorspace);
165
172 int width,
173 int height,
174 int channels,
175 const ColorSpace *colorspace,
176 bool predivide);
177
184 float *buffer, int width, int height, int channels, const ColorSpace *colorspace);
185
186void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer,
187 int offset_x,
188 int offset_y,
189 int width,
190 int height,
191 const ImBuf *ibuf,
192 bool store_premultiplied);
193void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
194 int offset_x,
195 int offset_y,
196 int width,
197 int height,
198 const ImBuf *ibuf,
199 bool store_premultiplied);
200
211 const float scene_linear[3]);
213 const float color_picking[3]);
214
220 const float scene_linear[3]);
222 const float srgb[3]);
223
230 const ColorManagedDisplay *display);
236 const ColorManagedDisplay *display);
237
239 float result[4],
240 const float pixel[4],
241 const ColorManagedViewSettings *view_settings,
242 const ColorManagedDisplaySettings *display_settings);
243
245 float result[3],
246 const float pixel[3],
247 const ColorManagedViewSettings *view_settings,
248 const ColorManagedDisplaySettings *display_settings);
249
251 ImBuf *ibuf,
252 const ColorManagedViewSettings *view_settings,
253 const ColorManagedDisplaySettings *display_settings);
254
268 bool save_as_render,
269 bool allocate_result,
270 const ImageFormatData *image_format);
271
273
274/* -------------------------------------------------------------------- */
277
279 const bContext *C,
280 ColorManagedViewSettings **r_view_settings,
281 ColorManagedDisplaySettings **r_display_settings);
282
286unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
287 const ColorManagedViewSettings *view_settings,
288 const ColorManagedDisplaySettings *display_settings,
289 void **cache_handle);
293unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle);
294
295void IMB_display_buffer_transform_apply(unsigned char *display_buffer,
296 float *linear_buffer,
297 int width,
298 int height,
299 int channels,
300 const ColorManagedViewSettings *view_settings,
301 const ColorManagedDisplaySettings *display_settings,
302 bool predivide);
303void IMB_display_buffer_transform_apply_float(float *float_display_buffer,
304 float *linear_buffer,
305 int width,
306 int height,
307 int channels,
308 const ColorManagedViewSettings *view_settings,
309 const ColorManagedDisplaySettings *display_settings,
310 bool predivide);
311
312void IMB_display_buffer_release(void *cache_handle);
313
315
316/* -------------------------------------------------------------------- */
319
329 const ColorManagedDisplay *display);
330
332
333/* -------------------------------------------------------------------- */
336
337int IMB_colormanagement_view_get_id_by_name(const char *name);
338const char *IMB_colormanagement_view_get_name_by_id(int index);
339
341
342/* -------------------------------------------------------------------- */
345
346int IMB_colormanagement_look_get_named_index(const char *name);
347const char *IMB_colormanagement_look_get_indexed_name(int index);
349const char *IMB_colormanagement_look_validate_for_view(const char *view_name,
350 const char *look_name);
351
353
354/* -------------------------------------------------------------------- */
357
360const char *IMB_colormanagement_colorspace_get_name(const ColorSpace *colorspace);
361const char *IMB_colormanagement_view_get_default_name(const char *display_name);
362const char *IMB_colormanagement_view_get_raw_or_default_name(const char *display_name);
363
365 ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf);
366
368
369/* -------------------------------------------------------------------- */
372
375 int *totitem,
376 const char *display_name);
378 int *totitem,
379 const char *view_name);
381
383
384/* -------------------------------------------------------------------- */
387
389 const float *linear_buffer,
390 const unsigned char *byte_buffer,
391 int stride,
392 int offset_x,
393 int offset_y,
394 const ColorManagedViewSettings *view_settings,
395 const ColorManagedDisplaySettings *display_settings,
396 int xmin,
397 int ymin,
398 int xmax,
399 int ymax);
400
402 ImBuf *ibuf,
403 const float *linear_buffer,
404 const unsigned char *byte_buffer,
405 int stride,
406 int offset_x,
407 int offset_y,
408 const ColorManagedViewSettings *view_settings,
409 const ColorManagedDisplaySettings *display_settings,
410 int xmin,
411 int ymin,
412 int xmax,
413 int ymax);
414
416 ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax);
417
419
420/* -------------------------------------------------------------------- */
423
425 const ColorManagedViewSettings *view_settings,
426 const ColorManagedDisplaySettings *display_settings);
428 const char *to_colorspace);
430void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4]);
432 float pixel[4]);
433void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3]);
435 float *pixel,
436 int channels);
438 float *buffer,
439 int width,
440 int height,
441 int channels,
442 bool predivide);
444 unsigned char *buffer,
445 int width,
446 int height,
447 int channels);
449
451
452/* -------------------------------------------------------------------- */
455
460 const ColorManagedDisplaySettings *display_settings,
461 float dither,
462 bool predivide);
480 const ColorManagedViewSettings *view_settings,
481 const ColorManagedDisplaySettings *display_settings,
482 const ColorSpace *from_colorspace,
483 float dither,
484 bool predivide,
485 bool do_overlay_merge);
489bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide);
495 const ColorSpace *from_colorspace,
496 float dither,
497 bool predivide);
498
505bool IMB_colormanagement_setup_glsl_draw_to_scene_linear(const char *from_colorspace_name,
506 bool predivide);
507
512
514
515/* -------------------------------------------------------------------- */
518
520 ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings);
521
522/* Roles */
523enum {
532};
533
535
536/* -------------------------------------------------------------------- */
539
540void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value);
542 int width,
543 float min,
544 float max);
545void IMB_colormanagement_wavelength_to_rgb(float r_dest[4], float value);
546void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width);
547
549
550#include "intern/colormanagement_inline.h" // IWYU pragma: export
blender::ocio::Display ColorManagedDisplay
Definition BLF_api.hh:35
#define BLI_INLINE
#define Display
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], const ColorSpace *colorspace)
BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3])
void IMB_colormanagement_transform_byte_to_float(float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
void IMB_colormanagement_assign_byte_colorspace(ImBuf *ibuf, const char *name)
void IMB_colormanagement_processor_apply_byte(ColormanageProcessor *cm_processor, unsigned char *buffer, int width, int height, int channels)
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], const ColorSpace *colorspace)
void IMB_colormanagement_colorspace_items_add(EnumPropertyItem **items, int *totitem)
bool IMB_colormanagement_set_whitepoint(const float whitepoint[3], float &temperature, float &tint)
const char * IMB_colormanagement_colorspace_get_indexed_name(int index)
ColormanageProcessor * IMB_colormanagement_colorspace_processor_new(const char *from_colorspace, const char *to_colorspace)
void IMB_colormanagement_assign_float_colorspace(ImBuf *ibuf, const char *name)
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
void IMB_colormanagement_wavelength_to_rgb(float r_dest[4], float value)
const char * IMB_colormanagement_display_get_none_name()
const ColorSpace * IMB_colormanagement_space_get_named(const char *name)
void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
unsigned char * IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle)
void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer, int offset_x, int offset_y, int width, int height, const ImBuf *ibuf, bool store_premultiplied)
blender::float3x3 IMB_colormanagement_get_scene_linear_to_xyz()
bool IMB_colormanagement_space_is_scene_linear(const ColorSpace *colorspace)
void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3], const float color_picking[3])
void IMB_colormanagement_view_items_add(EnumPropertyItem **items, int *totitem, const char *display_name)
const char * IMB_colormanagement_view_get_raw_or_default_name(const char *display_name)
unsigned char * IMB_display_buffer_acquire(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, void **cache_handle)
const char * IMB_colormanagement_look_get_default_name()
void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name)
bool IMB_colormanagement_setup_glsl_draw(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, float dither, bool predivide)
const char * IMB_colormanagement_look_get_indexed_name(int index)
bool IMB_colormanagement_space_name_is_srgb(const char *name)
bool IMB_colormanagement_space_name_is_scene_linear(const char *name)
void IMB_colormanagement_imbuf_make_display_space(ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
const char * IMB_colormanagement_look_validate_for_view(const char *view_name, const char *look_name)
void IMB_partial_display_buffer_update_threaded(ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer, int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, int xmin, int ymin, int xmax, int ymax)
void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, const ColorSpace *colorspace, bool predivide)
void IMB_colormanagement_transform_float(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
bool IMB_colormanagement_space_is_data(const ColorSpace *colorspace)
BLI_INLINE void IMB_colormanagement_scene_linear_to_rec709(float rec709[3], const float scene_linear[3])
const char * IMB_colormanagement_view_get_name_by_id(int index)
bool IMB_colormanagement_processor_is_noop(ColormanageProcessor *cm_processor)
void IMB_colormanagement_check_file_config(Main *bmain)
void IMB_colormanagement_blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max)
ImBuf * IMB_colormanagement_imbuf_for_write(ImBuf *ibuf, bool save_as_render, bool allocate_result, const ImageFormatData *image_format)
ColormanageProcessor * IMB_colormanagement_display_processor_new(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
bool IMB_colormanagement_space_name_is_data(const char *name)
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C, const ColorSpace *from_colorspace, float dither, bool predivide)
void IMB_colormanagement_init_default_view_settings(ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
const char * IMB_colormanagement_srgb_colorspace_name_get()
void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *display_settings, ColorManagedViewSettings *view_settings)
void IMB_colormanagement_colorspace_from_ibuf_ftype(ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf)
void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3])
BLI_INLINE void IMB_colormanagement_aces_to_scene_linear(float scene_linear[3], const float aces[3])
void IMB_colormanagegent_copy_settings(ImBuf *ibuf_src, ImBuf *ibuf_dst)
void IMB_colormanagement_processor_apply(ColormanageProcessor *cm_processor, float *buffer, int width, int height, int channels, bool predivide)
const char * IMB_colormanagement_colorspace_get_name(const ColorSpace *colorspace)
const char * IMB_colormanagement_space_from_filepath_rules(const char *filepath)
bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide)
void IMB_display_buffer_release(void *cache_handle)
@ COLOR_ROLE_DEFAULT_FLOAT
@ COLOR_ROLE_ACES_INTERCHANGE
@ COLOR_ROLE_DATA
@ COLOR_ROLE_DEFAULT_BYTE
@ COLOR_ROLE_SCENE_LINEAR
@ COLOR_ROLE_COLOR_PICKING
@ COLOR_ROLE_DEFAULT_SEQUENCER
@ COLOR_ROLE_TEXTURE_PAINTING
void IMB_colormanagement_get_whitepoint(const float temperature, const float tint, float whitepoint[3])
int IMB_colormanagement_view_get_id_by_name(const char *name)
BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3])
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_display_settings_from_ctx(const bContext *C, ColorManagedViewSettings **r_view_settings, ColorManagedDisplaySettings **r_display_settings)
blender::float3x3 IMB_colormanagement_get_xyz_to_scene_linear()
const char * IMB_colormanagement_display_get_indexed_name(int index)
BLI_INLINE void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3])
const char * IMB_colormanagement_view_get_default_name(const char *display_name)
void IMB_colormanagement_finish_glsl_draw()
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], bool predivide, const ColorSpace *colorspace)
BLI_INLINE void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3])
int IMB_colormanagement_look_get_named_index(const char *name)
BLI_INLINE void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3])
const char * IMB_colormanagement_display_get_default_view_transform_name(const ColorManagedDisplay *display)
void IMB_colormanagement_transform_byte(unsigned char *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
BLI_INLINE void IMB_colormanagement_scene_linear_to_aces(float aces[3], const float scene_linear[3])
BLI_INLINE void IMB_colormanagement_get_luminance_coefficients(float r_rgb[3])
void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem)
const ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3], const float scene_linear[3])
void IMB_colormanagement_scene_linear_to_colorspace(float *buffer, int width, int height, int channels, const ColorSpace *colorspace)
void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], const ColorManagedDisplay *display)
int IMB_colormanagement_colorspace_get_named_index(const char *name)
void IMB_display_buffer_transform_apply_float(float *float_display_buffer, float *linear_buffer, int width, int height, int channels, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool predivide)
void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer, int offset_x, int offset_y, int width, int height, const ImBuf *ibuf, bool store_premultiplied)
void IMB_partial_display_buffer_update(ImBuf *ibuf, const float *linear_buffer, const unsigned char *byte_buffer, int stride, int offset_x, int offset_y, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, int xmin, int ymin, int xmax, int ymax)
void IMB_display_buffer_transform_apply(unsigned char *display_buffer, float *linear_buffer, int width, int height, int channels, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, bool predivide)
void IMB_colormanagement_processor_apply_v4_predivide(ColormanageProcessor *cm_processor, float pixel[4])
void IMB_colormanagement_look_items_add(EnumPropertyItem **items, int *totitem, const char *view_name)
void IMB_colormanagement_processor_free(ColormanageProcessor *cm_processor)
const char * IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
bool IMB_colormanagement_setup_glsl_draw_to_scene_linear(const char *from_colorspace_name, bool predivide)
void IMB_partial_display_buffer_update_delayed(ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax)
void IMB_colormanagement_transform_v4(float pixel[4], const char *from_colorspace, const char *to_colorspace)
blender::ocio::ColorSpace ColorSpace
void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4])
int IMB_colormanagement_display_get_named_index(const char *name)
const char * IMB_colormanagement_get_float_colorspace(ImBuf *ibuf)
const char * IMB_colormanagement_display_get_default_name()
bool IMB_colormanagement_space_is_srgb(const ColorSpace *colorspace)
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, const ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
void IMB_colormanagement_processor_apply_pixel(ColormanageProcessor *cm_processor, float *pixel, int channels)
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], const ColorManagedDisplay *display)
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width)
#define C
Definition RandGen.cpp:29
MatBase< float, 3, 3 > float3x3
#define min(a, b)
Definition sort.cc:36
max
Definition text_draw.cc:251