Blender V4.3
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#include "BLI_sys_types.h"
13
15
16#define BCM_CONFIG_FILE "config.ocio"
17
22struct EnumPropertyItem;
23struct ImBuf;
24struct ImageFormatData;
25struct Main;
26struct bContext;
27
29struct ColorSpace;
30
31/* -------------------------------------------------------------------- */
34
36
38 ColorManagedViewSettings *view_settings);
39
41void IMB_colormanagement_check_is_data(ImBuf *ibuf, const char *name);
42void IMB_colormanagegent_copy_settings(ImBuf *ibuf_src, ImBuf *ibuf_dst);
45
48
55
57
69BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3]);
73BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char[3]);
74
78BLI_INLINE void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3]);
79BLI_INLINE void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3]);
81 const float rec709[3]);
83 const float scene_linear[3]);
85 const float aces[3]);
87 const float scene_linear[3]);
90
94void IMB_colormanagement_get_whitepoint(const float temperature,
95 const float tint,
96 float whitepoint[3]);
97bool IMB_colormanagement_set_whitepoint(const float whitepoint[3],
98 float &temperature,
99 float &tint);
100
102
103/* -------------------------------------------------------------------- */
106
110void IMB_colormanagement_transform(float *buffer,
111 int width,
112 int height,
113 int channels,
114 const char *from_colorspace,
115 const char *to_colorspace,
116 bool predivide);
122 int width,
123 int height,
124 int channels,
125 const char *from_colorspace,
126 const char *to_colorspace,
127 bool predivide);
131void IMB_colormanagement_transform_byte(unsigned char *buffer,
132 int width,
133 int height,
134 int channels,
135 const char *from_colorspace,
136 const char *to_colorspace);
137void IMB_colormanagement_transform_byte_threaded(unsigned char *buffer,
138 int width,
139 int height,
140 int channels,
141 const char *from_colorspace,
142 const char *to_colorspace);
146void IMB_colormanagement_transform_from_byte(float *float_buffer,
147 unsigned char *byte_buffer,
148 int width,
149 int height,
150 int channels,
151 const char *from_colorspace,
152 const char *to_colorspace);
154 unsigned char *byte_buffer,
155 int width,
156 int height,
157 int channels,
158 const char *from_colorspace,
159 const char *to_colorspace);
160void IMB_colormanagement_transform_v4(float pixel[4],
161 const char *from_colorspace,
162 const char *to_colorspace);
163
169void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace);
171 bool predivide,
172 ColorSpace *colorspace);
173
179void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpace *colorspace);
180
187 float *buffer, int width, int height, int channels, ColorSpace *colorspace, bool predivide);
188
195 float *buffer, int width, int height, int channels, ColorSpace *colorspace);
196
197void IMB_colormanagement_imbuf_to_byte_texture(unsigned char *out_buffer,
198 int offset_x,
199 int offset_y,
200 int width,
201 int height,
202 const ImBuf *ibuf,
203 bool store_premultiplied);
204void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
205 int offset_x,
206 int offset_y,
207 int width,
208 int height,
209 const ImBuf *ibuf,
210 bool store_premultiplied);
211
222 const float scene_linear[3]);
224 const float color_picking[3]);
225
231 const float scene_linear[3]);
233 const float srgb[3]);
234
246
248 float result[4],
249 const float pixel[4],
250 const ColorManagedViewSettings *view_settings,
251 const ColorManagedDisplaySettings *display_settings);
252
254 float result[3],
255 const float pixel[3],
256 const ColorManagedViewSettings *view_settings,
257 const ColorManagedDisplaySettings *display_settings);
258
260 ImBuf *ibuf,
261 const ColorManagedViewSettings *view_settings,
262 const ColorManagedDisplaySettings *display_settings);
263
277 bool save_as_render,
278 bool allocate_result,
279 const ImageFormatData *image_format);
280
282
283/* -------------------------------------------------------------------- */
286
288 const bContext *C,
289 ColorManagedViewSettings **r_view_settings,
290 ColorManagedDisplaySettings **r_display_settings);
291
295unsigned char *IMB_display_buffer_acquire(ImBuf *ibuf,
296 const ColorManagedViewSettings *view_settings,
297 const ColorManagedDisplaySettings *display_settings,
298 void **cache_handle);
302unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, void **cache_handle);
303
304void IMB_display_buffer_transform_apply(unsigned char *display_buffer,
305 float *linear_buffer,
306 int width,
307 int height,
308 int channels,
309 const ColorManagedViewSettings *view_settings,
310 const ColorManagedDisplaySettings *display_settings,
311 bool predivide);
312void IMB_display_buffer_transform_apply_float(float *float_display_buffer,
313 float *linear_buffer,
314 int width,
315 int height,
316 int channels,
317 const ColorManagedViewSettings *view_settings,
318 const ColorManagedDisplaySettings *display_settings,
319 bool predivide);
320
321void IMB_display_buffer_release(void *cache_handle);
322
324
325/* -------------------------------------------------------------------- */
328
338 ColorManagedDisplay *display);
339
341
342/* -------------------------------------------------------------------- */
345
348
350
351/* -------------------------------------------------------------------- */
354
358const char *IMB_colormanagement_look_validate_for_view(const char *view_name,
359 const char *look_name);
360
362
363/* -------------------------------------------------------------------- */
366
369const char *IMB_colormanagement_colorspace_get_name(const ColorSpace *colorspace);
370const char *IMB_colormanagement_view_get_default_name(const char *display_name);
371const char *IMB_colormanagement_view_get_raw_or_default_name(const char *display_name);
372
374 ColorManagedColorspaceSettings *colorspace_settings, ImBuf *ibuf);
375
377
378/* -------------------------------------------------------------------- */
381
384 int *totitem,
385 const char *display_name);
387 int *totitem,
388 const char *view_name);
390
392
393/* -------------------------------------------------------------------- */
396
398 const float *linear_buffer,
399 const unsigned char *byte_buffer,
400 int stride,
401 int offset_x,
402 int offset_y,
403 const ColorManagedViewSettings *view_settings,
404 const ColorManagedDisplaySettings *display_settings,
405 int xmin,
406 int ymin,
407 int xmax,
408 int ymax);
409
411 ImBuf *ibuf,
412 const float *linear_buffer,
413 const unsigned char *byte_buffer,
414 int stride,
415 int offset_x,
416 int offset_y,
417 const ColorManagedViewSettings *view_settings,
418 const ColorManagedDisplaySettings *display_settings,
419 int xmin,
420 int ymin,
421 int xmax,
422 int ymax);
423
425 ImBuf *ibuf, int xmin, int ymin, int xmax, int ymax);
426
428
429/* -------------------------------------------------------------------- */
432
434 const ColorManagedViewSettings *view_settings,
435 const ColorManagedDisplaySettings *display_settings);
437 const char *to_colorspace);
439void IMB_colormanagement_processor_apply_v4(ColormanageProcessor *cm_processor, float pixel[4]);
441 float pixel[4]);
442void IMB_colormanagement_processor_apply_v3(ColormanageProcessor *cm_processor, float pixel[3]);
444 float *pixel,
445 int channels);
447 float *buffer,
448 int width,
449 int height,
450 int channels,
451 bool predivide);
453 unsigned char *buffer,
454 int width,
455 int height,
456 int channels);
458
460
461/* -------------------------------------------------------------------- */
464
473 const ColorManagedDisplaySettings *display_settings,
474 float dither,
475 bool predivide);
493 const ColorManagedViewSettings *view_settings,
494 const ColorManagedDisplaySettings *display_settings,
495 ColorSpace *from_colorspace,
496 float dither,
497 bool predivide,
498 bool do_overlay_merge);
502bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide);
508 ColorSpace *from_colorspace,
509 float dither,
510 bool predivide);
515
517
518/* -------------------------------------------------------------------- */
521
523 ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings);
524
525/* Roles */
526enum {
534};
535
537
538/* -------------------------------------------------------------------- */
541
542void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value);
544 int width,
545 float min,
546 float max);
547void IMB_colormanagement_wavelength_to_rgb(float r_dest[4], float value);
548void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width);
549
551
#define BLI_INLINE
void IMB_colormanagement_pixel_to_display_space_v3(float result[3], const float pixel[3], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
@ COLOR_ROLE_DEFAULT_FLOAT
@ 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_assign_byte_colorspace(ImBuf *ibuf, const char *name)
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], ColorManagedDisplay *display)
void IMB_colormanagement_processor_apply_byte(ColormanageProcessor *cm_processor, unsigned char *buffer, int width, int height, int channels)
bool IMB_colormanagement_space_is_data(ColorSpace *colorspace)
bool IMB_colormanagement_support_glsl_draw(const ColorManagedViewSettings *view_settings)
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()
bool IMB_colormanagement_space_is_srgb(ColorSpace *colorspace)
void IMB_colormanagement_pixel_to_display_space_v4(float result[4], const float pixel[4], const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
ColorManagedDisplay * IMB_colormanagement_display_get_named(const char *name)
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(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)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace)
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)
const char * IMB_colormanagement_display_get_default_view_transform_name(ColorManagedDisplay *display)
int IMB_colormanagement_view_get_named_index(const char *name)
BLI_INLINE void IMB_colormanagement_scene_linear_to_rec709(float rec709[3], const float scene_linear[3])
bool IMB_colormanagement_processor_is_noop(ColormanageProcessor *cm_processor)
void IMB_colormanagement_check_file_config(Main *bmain)
BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char[3])
void IMB_colormanagement_blackbody_temperature_to_rgb_table(float *r_table, int width, float min, float max)
void IMB_colormanagement_transform_from_byte_threaded(float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
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)
void IMB_colormanagement_transform_from_byte(float *float_buffer, unsigned char *byte_buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
void IMB_colormanagement_init_default_view_settings(ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
void IMB_colormanagement_transform_threaded(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
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)
void IMB_colormanagement_transform_byte_threaded(unsigned char *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace)
bool IMB_colormanagement_setup_glsl_draw_ctx(const bContext *C, float dither, bool predivide)
void IMB_display_buffer_release(void *cache_handle)
void IMB_colormanagement_get_whitepoint(const float temperature, const float tint, float whitepoint[3])
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])
void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], ColorSpace *colorspace)
const char * IMB_colormanagement_view_get_default_name(const char *display_name)
void IMB_colormanagement_finish_glsl_draw()
void IMB_colormanagement_scene_linear_to_colorspace(float *buffer, int width, int height, int channels, 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])
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])
const char * IMB_colormanagement_view_get_indexed_name(int index)
void IMB_colormanagement_display_items_add(EnumPropertyItem **items, int *totitem)
void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3], const float scene_linear[3])
bool IMB_colormanagement_setup_glsl_draw_from_space(const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, ColorSpace *from_colorspace, float dither, bool predivide, bool do_overlay_merge)
void IMB_colormanagement_blackbody_temperature_to_rgb(float r_dest[4], float value)
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)
bool IMB_colormanagement_setup_glsl_draw_from_space_ctx(const bContext *C, ColorSpace *from_colorspace, float dither, bool predivide)
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)
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)
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], bool predivide, ColorSpace *colorspace)
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
void IMB_colormanagement_transform(float *buffer, int width, int height, int channels, const char *from_colorspace, const char *to_colorspace, bool predivide)
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()
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_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, ColorSpace *colorspace, bool predivide)
void IMB_colormanagement_wavelength_to_rgb_table(float *r_table, int width)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
#define C
Definition RandGen.cpp:29
MatBase< float, 3, 3 > float3x3
#define min(a, b)
Definition sort.c:32
char name[MAX_COLORSPACE_NAME]
float max