Blender V5.0
math_color_inline.cc File Reference
#include "BLI_math_base.h"
#include "BLI_math_color.h"
#include <cmath>

Go to the source code of this file.

Macros

#define __MATH_COLOR_INLINE_C__

Functions

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 rgb_uchar_to_float (float r_col[3], const uchar col_ub[3])
MINLINE void rgba_uchar_to_float (float r_col[4], const uchar col_ub[4])
MINLINE void rgb_float_to_uchar (uchar r_col[3], const float col_f[3])
MINLINE void rgba_float_to_uchar (uchar r_col[4], const float col_f[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 hash_iqint3_f (const uint32_t x, const uint32_t y)
MINLINE float dither_random_value (int x, int y)
MINLINE void float_to_byte_dither_v3 (unsigned char b[3], const float f[3], float dither, int x, int y)
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])
sRGB/Gray-Scale Functions
Warning
Only use for colors known to be in sRGB space, like user interface and themes. Scene color should use IMB_colormanagement_get_luminance instead.
MINLINE float srgb_to_grayscale (const float rgb[3])
MINLINE unsigned char srgb_to_grayscale_byte (const unsigned char rgb[3])

Variables

float BLI_color_from_srgb_table [256]
unsigned short BLI_color_to_srgb_table [0x10000]

Macro Definition Documentation

◆ __MATH_COLOR_INLINE_C__

#define __MATH_COLOR_INLINE_C__

Definition at line 15 of file math_color_inline.cc.

Function Documentation

◆ compare_rgb_uchar()

MINLINE int compare_rgb_uchar ( const unsigned char col_a[3],
const unsigned char col_b[3],
const int limit )

Definition at line 240 of file math_color_inline.cc.

References abs, b, and MINLINE.

◆ cpack_cpy_3ub()

MINLINE void cpack_cpy_3ub ( unsigned char r_col[3],
const unsigned int pack )

Definition at line 202 of file math_color_inline.cc.

References MINLINE.

◆ dither_random_value()

MINLINE float dither_random_value ( int x,
int y )

Returns triangle noise in [-1..+1) range, given integer pixel coordinates. Triangle distribution which gives a more final uniform noise, see "Banding in Games: A Noisy Rant" by Mikkel Gjoel (slide 27) https://loopit.dk/banding_in_games.pdf

Definition at line 268 of file math_color_inline.cc.

References fabsf, hash_iqint3_f(), MINLINE, signf(), sqrtf, v, x, and y.

Referenced by float_to_byte_dither_v3(), float_to_byte_dither_v4(), and ushort_to_byte_dither_v4().

◆ float_to_byte_dither_v3()

MINLINE void float_to_byte_dither_v3 ( unsigned char b[3],
const float f[3],
float dither,
int x,
int y )

◆ hash_iqint3_f()

MINLINE float hash_iqint3_f ( const uint32_t x,
const uint32_t y )

Definition at line 260 of file math_color_inline.cc.

References float, MINLINE, x, and y.

Referenced by dither_random_value().

◆ linearrgb_to_srgb_predivide_v4()

MINLINE void linearrgb_to_srgb_predivide_v4 ( float srgb[4],
const float linear[4] )

◆ linearrgb_to_srgb_uchar3()

MINLINE void linearrgb_to_srgb_uchar3 ( unsigned char srgb[3],
const float linear[3] )

◆ linearrgb_to_srgb_uchar4()

◆ linearrgb_to_srgb_ushort4()

MINLINE void linearrgb_to_srgb_ushort4 ( unsigned short srgb[4],
const float linear[4] )

◆ linearrgb_to_srgb_v4()

◆ premul_float_to_straight_uchar()

◆ premul_to_straight_v4()

MINLINE void premul_to_straight_v4 ( float color[4])

Definition at line 307 of file math_color_inline.cc.

References MINLINE, and premul_to_straight_v4_v4().

Referenced by project_paint_uvpixel_init().

◆ premul_to_straight_v4_v4()

◆ rgb_float_to_uchar()

◆ rgb_uchar_to_float()

◆ rgba_float_args_set()

◆ rgba_float_to_uchar()

◆ rgba_uchar_args_set()

MINLINE void rgba_uchar_args_set ( uchar col[4],
const uchar r,
const uchar g,
const uchar b,
const uchar a )

Definition at line 173 of file math_color_inline.cc.

References b, col, and MINLINE.

Referenced by action_group_colors_sync().

◆ rgba_uchar_args_test_set()

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 191 of file math_color_inline.cc.

References b, col, and MINLINE.

◆ rgba_uchar_to_float()

MINLINE void rgba_uchar_to_float ( float r_col[4],
const uchar col_ub[4] )

◆ srgb_to_grayscale()

MINLINE float srgb_to_grayscale ( const float rgb[3])

Compute luminance using Rec.709 primaries, for sRGB and linear Rec.709.

Only use for colors known to be in sRGB space, like user interface and themes. Scene colors should use IMB_colormanagement_get_luminance instead.

Definition at line 218 of file math_color_inline.cc.

References MINLINE.

Referenced by button2d_draw_intern(), ED_view3d_text_colors_get(), file_draw_preview(), file_draw_special_image(), ui_tooltip_region_draw_cb(), and widget_swatch().

◆ srgb_to_grayscale_byte()

◆ srgb_to_linearrgb_predivide_v4()

MINLINE void srgb_to_linearrgb_predivide_v4 ( float linear[4],
const float srgb[4] )

◆ srgb_to_linearrgb_uchar4()

◆ srgb_to_linearrgb_uchar4_predivide()

MINLINE void srgb_to_linearrgb_uchar4_predivide ( float linear[4],
const unsigned char srgb[4] )

◆ srgb_to_linearrgb_v4()

◆ straight_to_premul_v4()

◆ straight_to_premul_v4_v4()

MINLINE void straight_to_premul_v4_v4 ( float premul[4],
const float straight[4] )

◆ straight_uchar_to_premul_float()

◆ to_srgb_table_lookup()

MINLINE unsigned short to_srgb_table_lookup ( const float f)

Definition at line 103 of file math_color_inline.cc.

References BLI_color_to_srgb_table, and MINLINE.

Referenced by linearrgb_to_srgb_ushort4().

Variable Documentation

◆ BLI_color_from_srgb_table

◆ BLI_color_to_srgb_table

unsigned short BLI_color_to_srgb_table[0x10000]
extern

Definition at line 707 of file math_color.cc.

Referenced by BLI_init_srgb_conversion(), and to_srgb_table_lookup().