Blender
V3.3
|
#include "BLI_math_base.h"
#include "BLI_math_color.h"
#include "BLI_utildefines.h"
#include <math.h>
Go to the source code of this file.
Macros | |
#define | __MATH_COLOR_INLINE_C__ |
Functions | |
MINLINE void | srgb_to_linearrgb_v3_v3 (float linear[3], const float srgb[3]) |
MINLINE void | linearrgb_to_srgb_v3_v3 (float srgb[3], const float linear[3]) |
MINLINE void | srgb_to_linearrgb_v4 (float linear[4], const float srgb[4]) |
MINLINE void | linearrgb_to_srgb_v4 (float srgb[4], const float linear[4]) |
MINLINE void | linearrgb_to_srgb_uchar3 (unsigned char srgb[3], const float linear[3]) |
MINLINE void | linearrgb_to_srgb_uchar4 (unsigned char srgb[4], const float linear[4]) |
MINLINE void | srgb_to_linearrgb_predivide_v4 (float linear[4], const float srgb[4]) |
MINLINE void | linearrgb_to_srgb_predivide_v4 (float srgb[4], const float linear[4]) |
MINLINE unsigned short | to_srgb_table_lookup (const float f) |
MINLINE void | linearrgb_to_srgb_ushort4 (unsigned short srgb[4], const float linear[4]) |
MINLINE void | srgb_to_linearrgb_uchar4 (float linear[4], const unsigned char srgb[4]) |
MINLINE void | srgb_to_linearrgb_uchar4_predivide (float linear[4], const unsigned char srgb[4]) |
MINLINE void | rgba_uchar_args_set (uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) |
MINLINE void | rgba_float_args_set (float col[4], const float r, const float g, const float b, const float a) |
MINLINE void | rgba_uchar_args_test_set (uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a) |
MINLINE void | cpack_cpy_3ub (unsigned char r_col[3], const unsigned int pack) |
MINLINE int | compare_rgb_uchar (const unsigned char col_a[3], const unsigned char col_b[3], const int limit) |
MINLINE float | dither_random_value (float s, float t) |
MINLINE void | float_to_byte_dither_v3 (unsigned char b[3], const float f[3], float dither, float s, float t) |
MINLINE void | premul_to_straight_v4_v4 (float straight[4], const float premul[4]) |
MINLINE void | premul_to_straight_v4 (float color[4]) |
MINLINE void | straight_to_premul_v4_v4 (float premul[4], const float straight[4]) |
MINLINE void | straight_to_premul_v4 (float color[4]) |
MINLINE void | straight_uchar_to_premul_float (float result[4], const unsigned char color[4]) |
MINLINE void | premul_float_to_straight_uchar (unsigned char *result, const float color[4]) |
RGB/Gray-Scale Functions | |
| |
MINLINE float | rgb_to_grayscale (const float rgb[3]) |
MINLINE unsigned char | rgb_to_grayscale_byte (const unsigned char rgb[3]) |
Variables | |
float | BLI_color_from_srgb_table [256] |
unsigned short | BLI_color_to_srgb_table [0x10000] |
#define __MATH_COLOR_INLINE_C__ |
Definition at line 15 of file math_color_inline.c.
MINLINE int compare_rgb_uchar | ( | const unsigned char | col_a[3], |
const unsigned char | col_b[3], | ||
const int | limit | ||
) |
Definition at line 270 of file math_color_inline.c.
References blender::math::abs(), usdtokens::b(), usdtokens::g(), and r.
Definition at line 238 of file math_color_inline.c.
Return triangle noise in [-0.5..1.5] range.
Definition at line 288 of file math_color_inline.c.
References floorf, sinf, and t.
Referenced by float_to_byte_dither_v3(), float_to_byte_dither_v4(), and ushort_to_byte_dither_v4().
MINLINE void float_to_byte_dither_v3 | ( | unsigned char | b[3], |
const float | f[3], | ||
float | dither, | ||
float | s, | ||
float | t | ||
) |
Definition at line 303 of file math_color_inline.c.
References usdtokens::b(), dither_random_value(), t, and unit_float_to_uchar_clamp().
Referenced by do_projectpaint_draw(), and do_projectpaint_thread().
Definition at line 133 of file math_color_inline.c.
References linearrgb_to_srgb_v3_v3().
Referenced by IMB_buffer_byte_from_byte(), IMB_buffer_float_from_byte(), and IMB_buffer_float_from_float().
Definition at line 89 of file math_color_inline.c.
References linearrgb_to_srgb_v3_v3(), and unit_float_to_uchar_clamp_v3.
Referenced by paint_2d_bucket_fill(), and project_paint_uvpixel_init().
Definition at line 97 of file math_color_inline.c.
References linearrgb_to_srgb_v4(), and unit_float_to_uchar_clamp_v4.
Referenced by blender::BLI_color_convert_to_theme4b(), convert_float_color_to_byte_color(), blender::ColorSceneLinear4f< Alpha >::encode(), and Freestyle::BlenderStrokeRenderer::GenerateStrokeMesh().
Definition at line 176 of file math_color_inline.c.
References to_srgb_table_lookup(), and unit_float_to_ushort_clamp().
Referenced by IMB_buffer_byte_from_float().
Definition at line 69 of file math_color_inline.c.
References linearrgb_to_srgb().
Referenced by FallbackTransform::applyRGB(), BKE_palette_from_hash(), do_projectpaint_draw(), do_projectpaint_thread(), blender::bke::from_float(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), IMB_colormanagement_scene_linear_to_srgb_v3(), imb_savetiff(), linearrgb_to_srgb_predivide_v4(), linearrgb_to_srgb_uchar3(), linearrgb_to_srgb_v4(), paint_2d_gradient_fill(), paint_get_tex_pixel_col(), paint_sample_color(), TEST(), ui_but_paste_color(), ui_draw_but_CURVE(), and blender::io::obj::OBJWriter::write_vertex_coords().
Definition at line 83 of file math_color_inline.c.
References linearrgb_to_srgb_v3_v3().
Referenced by blender::BLI_color_convert_to_theme4f(), create_mono_icon_with_border(), IMB_buffer_byte_from_byte(), IMB_buffer_float_from_byte(), IMB_buffer_float_from_float(), linearrgb_to_srgb_uchar4(), and vertex_to_loop_colors_exec().
Definition at line 362 of file math_color_inline.c.
References color, result, and unit_float_to_uchar_clamp().
Referenced by color_balance_byte_byte(), curves_apply_threaded(), do_alphaover_effect_byte(), do_alphaunder_effect_byte(), do_gammacross_effect_byte(), do_projectpaint_soften(), do_wipe_effect_byte(), paint_2d_ibuf_rgb_set(), project_paint_PickColor(), tonemapmodifier_apply_threaded_photoreceptor(), tonemapmodifier_apply_threaded_simple(), and whiteBalance_apply_threaded().
Definition at line 332 of file math_color_inline.c.
References color, and premul_to_straight_v4_v4().
Referenced by blender::compositor::BrightnessOperation::execute_pixel_sampled(), IMB_buffer_float_unpremultiply(), and project_paint_uvpixel_init().
Definition at line 315 of file math_color_inline.c.
Referenced by copy_original_alpha_channel(), ibuftoimage(), IMB_buffer_byte_from_float(), IMB_buffer_byte_from_float_mask(), IMB_colormanagement_imbuf_to_float_texture(), imb_savepng(), partial_buffer_update_rect(), premul_to_straight_v4(), blender::ColorSceneLinear4f< Alpha >::unpremultiply_alpha(), and blender::compositor::BrightnessOperation::update_memory_buffer_partial().
ITU-R BT.709 primaries https://en.wikipedia.org/wiki/Relative_luminance
Real values are: Y = 0.2126390059(R) + 0.7151686788(G) + 0.0721923154(B)
according to: "Derivation of Basic Television Color Equations", RP 177-1993
As this sums slightly above 1.0, the document recommends to use: 0.2126(R) + 0.7152(G) + 0.0722(B)
, as used here.
The high precision values are used to calculate the rounded byte weights so they add up to 255: 54(R) + 182(G) + 19(B)
Definition at line 256 of file math_color_inline.c.
References usdtokens::rgb().
Referenced by button2d_draw_intern(), blender::bke::color_to_bool(), blender::bke::color_to_float(), blender::bke::color_to_int(), file_draw_preview(), blender::nodes::node_fn_compare_cc::get_multi_function(), ui_tooltip_region_draw_cb(), and widget_swatch().
MINLINE unsigned char rgb_to_grayscale_byte | ( | const unsigned char | rgb[3] | ) |
Definition at line 261 of file math_color_inline.c.
References usdtokens::rgb().
Referenced by color_ensure_contrast_v3(), icon_draw_size(), widget_active_color(), and widget_state_numslider().
MINLINE void rgba_float_args_set | ( | float | col[4], |
const float | r, | ||
const float | g, | ||
const float | b, | ||
const float | a | ||
) |
Definition at line 218 of file math_color_inline.c.
References Freestyle::a, usdtokens::b(), col, usdtokens::g(), and r.
Referenced by default_paint_slot_color_get(), blender::ed::space_node::frame_node_draw(), blender::ed::space_node::node_draw_basis(), and blender::ed::space_node::node_draw_hidden().
MINLINE void rgba_uchar_args_set | ( | uchar | col[4], |
const uchar | r, | ||
const uchar | g, | ||
const uchar | b, | ||
const uchar | a | ||
) |
Definition at line 209 of file math_color_inline.c.
References Freestyle::a, usdtokens::b(), col, usdtokens::g(), and r.
Referenced by action_group_colors_sync().
MINLINE void rgba_uchar_args_test_set | ( | uchar | col[4], |
const uchar | r, | ||
const uchar | g, | ||
const uchar | b, | ||
const uchar | a | ||
) |
Definition at line 227 of file math_color_inline.c.
References Freestyle::a, usdtokens::b(), col, usdtokens::g(), and r.
Definition at line 110 of file math_color_inline.c.
References srgb_to_linearrgb_v3_v3().
Referenced by IMB_buffer_byte_from_byte(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), and srgb_to_linearrgb_uchar4_predivide().
Definition at line 184 of file math_color_inline.c.
References BLI_color_from_srgb_table.
Referenced by blender::BLI_color_convert_to_scene_linear(), create_mono_icon_with_border(), blender::ColorSceneLinearByteEncoded4b< Alpha >::decode(), blender::io::obj::geom_add_mrgb_colors(), IMB_buffer_float_from_byte(), project_paint_uvpixel_init(), and srgb_to_linearrgb_uchar4_predivide().
Definition at line 192 of file math_color_inline.c.
References srgb_to_linearrgb_predivide_v4(), and srgb_to_linearrgb_uchar4().
Referenced by IMB_buffer_float_from_byte().
Definition at line 62 of file math_color_inline.c.
References srgb_to_linearrgb().
Referenced by FallbackTransform::applyRGB(), blo_do_versions_250(), blo_do_versions_280(), camera_view3d_reconstruction(), drop_color_invoke(), blender::io::obj::geom_add_vertex(), gpencil_vertexpaint_brush_init(), image_buf_fill_checker_slice(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), IMB_colormanagement_imbuf_to_float_texture(), IMB_colormanagement_srgb_to_scene_linear_v3(), blender::ed::sculpt_paint::paint::image::PaintingKernel< ImageBuffer >::init_brush_color(), blender::ed::sculpt_paint::image::ops::paint::ImagePaintMode::paint_bucket_fill(), paint_proj_stroke_ps(), srgb_to_linearrgb_predivide_v4(), srgb_to_linearrgb_v4(), TEST(), blender::bke::to_float(), and ui_but_copy_color().
Definition at line 77 of file math_color_inline.c.
References srgb_to_linearrgb_v3_v3().
Referenced by add_ibuf_size(), blf_draw_buffer__start(), blender::BLI_color_convert_to_scene_linear(), blo_do_versions_280(), buf_rectfill_area(), create_mono_icon_with_border(), DRW_globals_update(), ED_gpencil_fill_vertex_color_set(), ED_gpencil_point_vertex_color_set(), ED_gpencil_sbuffer_vertex_color_set(), gpencil_lineart_material(), gpencil_monkey_color(), gpencil_stroke_material(), gpencil_vertexpaint_set_exec(), IMB_buffer_byte_from_byte(), IMB_buffer_byte_from_float(), IMB_buffer_float_from_float(), loop_to_vertex_colors_exec(), OVERLAY_edit_uv_cache_init(), OVERLAY_fade_cache_init(), OVERLAY_grid_cache_init(), OVERLAY_mode_transfer_cache_populate(), SEQ_render_pixel_from_sequencer_space_v4(), and set_pchan_color().
Definition at line 346 of file math_color_inline.c.
References color, and straight_to_premul_v4_v4().
Referenced by blender::nodes::node_geo_image_texture_cc::ImageFieldsFunction::call(), do_display_buffer_apply_thread(), blender::compositor::BrightnessOperation::execute_pixel_sampled(), IMB_buffer_float_premultiply(), paint_2d_bucket_fill(), paint_2d_fill_add_pixel_byte(), paint_sample_color(), partial_buffer_update_rect(), and blender::compositor::BrightnessOperation::update_memory_buffer_partial().
Definition at line 337 of file math_color_inline.c.
Referenced by copy_original_alpha_channel(), blender::ColorSceneLinear4f< Alpha >::premultiply_alpha(), project_paint_uvpixel_init(), and straight_to_premul_v4().
Definition at line 351 of file math_color_inline.c.
Referenced by color_balance_byte_byte(), curves_apply_threaded(), do_alphaover_effect_byte(), do_alphaunder_effect_byte(), do_gammacross_effect_byte(), do_projectpaint_soften(), do_wipe_effect_byte(), paint_2d_ibuf_rgb_get(), project_paint_PickColor(), tonemapmodifier_apply(), tonemapmodifier_apply_threaded_photoreceptor(), tonemapmodifier_apply_threaded_simple(), and whiteBalance_apply_threaded().
Definition at line 161 of file math_color_inline.c.
References BLI_color_to_srgb_table.
Referenced by linearrgb_to_srgb_ushort4().
|
extern |
Definition at line 517 of file math_color.c.
Referenced by BLI_init_srgb_conversion(), blender::draw::AttributeTypeConverter< ColorGeometry4b, gpuMeshCol >::convert_value(), GPU_pbvh_mesh_buffers_update(), particle_pack_mcol(), and srgb_to_linearrgb_uchar4().
|
extern |
Definition at line 518 of file math_color.c.
Referenced by BLI_init_srgb_conversion(), and to_srgb_table_lookup().