Blender  V2.93
Classes | Macros | Typedefs | Functions
colortools.c File Reference
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include "MEM_guardedalloc.h"
#include "DNA_color_types.h"
#include "DNA_curve_types.h"
#include "BLI_blenlib.h"
#include "BLI_math.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_colortools.h"
#include "BKE_curve.h"
#include "BKE_fcurve.h"
#include "IMB_colormanagement.h"
#include "IMB_imbuf_types.h"
#include "BLO_read_write.h"

Go to the source code of this file.

Classes

struct  ScopesUpdateData
 
struct  ScopesUpdateDataChunk
 

Macros

#define p2_h1   ((p2)-3)
 
#define p2_h2   ((p2) + 3)
 
#define INV_255   (1.0f / 255.0f)
 

Typedefs

typedef struct ScopesUpdateData ScopesUpdateData
 
typedef struct ScopesUpdateDataChunk ScopesUpdateDataChunk
 

Functions

void BKE_curvemapping_set_defaults (CurveMapping *cumap, int tot, float minx, float miny, float maxx, float maxy)
 
CurveMappingBKE_curvemapping_add (int tot, float minx, float miny, float maxx, float maxy)
 
void BKE_curvemapping_free_data (CurveMapping *cumap)
 
void BKE_curvemapping_free (CurveMapping *cumap)
 
void BKE_curvemapping_copy_data (CurveMapping *target, const CurveMapping *cumap)
 
CurveMappingBKE_curvemapping_copy (const CurveMapping *cumap)
 
void BKE_curvemapping_set_black_white_ex (const float black[3], const float white[3], float r_bwmul[3])
 
void BKE_curvemapping_set_black_white (CurveMapping *cumap, const float black[3], const float white[3])
 
bool BKE_curvemap_remove_point (CurveMap *cuma, CurveMapPoint *point)
 
void BKE_curvemap_remove (CurveMap *cuma, const short flag)
 
CurveMapPointBKE_curvemap_insert (CurveMap *cuma, float x, float y)
 
void BKE_curvemap_reset (CurveMap *cuma, const rctf *clipr, int preset, int slope)
 
void BKE_curvemap_handle_set (CurveMap *cuma, int type)
 
static void calchandle_curvemap (BezTriple *bezt, const BezTriple *prev, const BezTriple *next)
 
static float curvemap_calc_extend (const CurveMapping *cumap, const CurveMap *cuma, float x, const float first[2], const float last[2])
 
static void curvemap_make_table (const CurveMapping *cumap, CurveMap *cuma)
 
void BKE_curvemapping_premultiply (CurveMapping *cumap, int restore)
 
static int sort_curvepoints (const void *a1, const void *a2)
 
void BKE_curvemapping_changed (CurveMapping *cumap, const bool rem_doubles)
 
void BKE_curvemapping_changed_all (CurveMapping *cumap)
 
void BKE_curvemapping_reset_view (CurveMapping *cumap)
 
float BKE_curvemap_evaluateF (const CurveMapping *cumap, const CurveMap *cuma, float value)
 
float BKE_curvemapping_evaluateF (const CurveMapping *cumap, int cur, float value)
 
void BKE_curvemapping_evaluate3F (const CurveMapping *cumap, float vecout[3], const float vecin[3])
 
void BKE_curvemapping_evaluateRGBF (const CurveMapping *cumap, float vecout[3], const float vecin[3])
 
static void curvemapping_evaluateRGBF_filmlike (const CurveMapping *cumap, float vecout[3], const float vecin[3], const int channel_offset[3])
 
void BKE_curvemapping_evaluate_premulRGBF_ex (const CurveMapping *cumap, float vecout[3], const float vecin[3], const float black[3], const float bwmul[3])
 
void BKE_curvemapping_evaluate_premulRGBF (const CurveMapping *cumap, float vecout[3], const float vecin[3])
 
void BKE_curvemapping_evaluate_premulRGB (const CurveMapping *cumap, unsigned char vecout_byte[3], const unsigned char vecin_byte[3])
 
bool BKE_curvemapping_RGBA_does_something (const CurveMapping *cumap)
 
void BKE_curvemapping_init (CurveMapping *cumap)
 
void BKE_curvemapping_table_RGBA (const CurveMapping *cumap, float **array, int *size)
 
void BKE_curvemapping_blend_write (BlendWriter *writer, const CurveMapping *cumap)
 
void BKE_curvemapping_curves_blend_write (BlendWriter *writer, const CurveMapping *cumap)
 
void BKE_curvemapping_blend_read (BlendDataReader *reader, CurveMapping *cumap)
 
BLI_INLINE int get_bin_float (float f)
 
static void save_sample_line (Scopes *scopes, const int idx, const float fx, const float rgb[3], const float ycc[3])
 
void BKE_histogram_update_sample_line (Histogram *hist, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
static void scopes_update_cb (void *__restrict userdata, const int y, const TaskParallelTLS *__restrict tls)
 
static void scopes_update_reduce (const void *__restrict UNUSED(userdata), void *__restrict chunk_join, void *__restrict chunk)
 
void BKE_scopes_update (Scopes *scopes, ImBuf *ibuf, const ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings)
 
void BKE_scopes_free (Scopes *scopes)
 
void BKE_scopes_new (Scopes *scopes)
 
void BKE_color_managed_display_settings_init (ColorManagedDisplaySettings *settings)
 
void BKE_color_managed_display_settings_copy (ColorManagedDisplaySettings *new_settings, const ColorManagedDisplaySettings *settings)
 
void BKE_color_managed_view_settings_init_render (ColorManagedViewSettings *view_settings, const ColorManagedDisplaySettings *display_settings, const char *view_transform)
 
void BKE_color_managed_view_settings_init_default (struct ColorManagedViewSettings *view_settings, const struct ColorManagedDisplaySettings *display_settings)
 
void BKE_color_managed_view_settings_copy (ColorManagedViewSettings *new_settings, const ColorManagedViewSettings *settings)
 
void BKE_color_managed_view_settings_free (ColorManagedViewSettings *settings)
 
void BKE_color_managed_view_settings_blend_write (BlendWriter *writer, ColorManagedViewSettings *settings)
 
void BKE_color_managed_view_settings_blend_read_data (BlendDataReader *reader, ColorManagedViewSettings *settings)
 
void BKE_color_managed_colorspace_settings_init (ColorManagedColorspaceSettings *colorspace_settings)
 
void BKE_color_managed_colorspace_settings_copy (ColorManagedColorspaceSettings *colorspace_settings, const ColorManagedColorspaceSettings *settings)
 
bool BKE_color_managed_colorspace_settings_equals (const ColorManagedColorspaceSettings *settings1, const ColorManagedColorspaceSettings *settings2)
 

Macro Definition Documentation

◆ INV_255

#define INV_255   (1.0f / 255.0f)

Definition at line 1266 of file colortools.c.

◆ p2_h1

#define p2_h1   ((p2)-3)

◆ p2_h2

#define p2_h2   ((p2) + 3)

Typedef Documentation

◆ ScopesUpdateData

◆ ScopesUpdateDataChunk

Function Documentation

◆ BKE_color_managed_colorspace_settings_copy()

void BKE_color_managed_colorspace_settings_copy ( ColorManagedColorspaceSettings colorspace_settings,
const ColorManagedColorspaceSettings settings 
)

Definition at line 1852 of file colortools.c.

References BLI_strncpy(), and ColorManagedColorspaceSettings::name.

◆ BKE_color_managed_colorspace_settings_equals()

bool BKE_color_managed_colorspace_settings_equals ( const ColorManagedColorspaceSettings settings1,
const ColorManagedColorspaceSettings settings2 
)

Definition at line 1859 of file colortools.c.

References ColorManagedColorspaceSettings::name, and STREQ.

◆ BKE_color_managed_colorspace_settings_init()

void BKE_color_managed_colorspace_settings_init ( ColorManagedColorspaceSettings colorspace_settings)

Definition at line 1846 of file colortools.c.

References BLI_strncpy(), and ColorManagedColorspaceSettings::name.

Referenced by image_init(), and movie_clip_init_data().

◆ BKE_color_managed_display_settings_copy()

void BKE_color_managed_display_settings_copy ( ColorManagedDisplaySettings new_settings,
const ColorManagedDisplaySettings settings 
)

Definition at line 1760 of file colortools.c.

References BLI_strncpy(), and ColorManagedDisplaySettings::display_device.

◆ BKE_color_managed_display_settings_init()

void BKE_color_managed_display_settings_init ( ColorManagedDisplaySettings settings)

◆ BKE_color_managed_view_settings_blend_read_data()

void BKE_color_managed_view_settings_blend_read_data ( BlendDataReader reader,
ColorManagedViewSettings settings 
)

◆ BKE_color_managed_view_settings_blend_write()

void BKE_color_managed_view_settings_blend_write ( BlendWriter writer,
ColorManagedViewSettings settings 
)

◆ BKE_color_managed_view_settings_copy()

void BKE_color_managed_view_settings_copy ( ColorManagedViewSettings new_settings,
const ColorManagedViewSettings settings 
)

◆ BKE_color_managed_view_settings_free()

void BKE_color_managed_view_settings_free ( ColorManagedViewSettings settings)

◆ BKE_color_managed_view_settings_init_default()

void BKE_color_managed_view_settings_init_default ( struct ColorManagedViewSettings view_settings,
const struct ColorManagedDisplaySettings display_settings 
)

Definition at line 1793 of file colortools.c.

References IMB_colormanagement_init_default_view_settings().

Referenced by BKE_imformat_defaults().

◆ BKE_color_managed_view_settings_init_render()

void BKE_color_managed_view_settings_init_render ( ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings,
const char *  view_transform 
)

◆ BKE_curvemap_evaluateF()

float BKE_curvemap_evaluateF ( const CurveMapping cumap,
const CurveMap cuma,
float  value 
)

◆ BKE_curvemap_handle_set()

void BKE_curvemap_handle_set ( CurveMap cuma,
int  type 
)

◆ BKE_curvemap_insert()

CurveMapPoint* BKE_curvemap_insert ( CurveMap cuma,
float  x,
float  y 
)

◆ BKE_curvemap_remove()

void BKE_curvemap_remove ( CurveMap cuma,
const short  flag 
)

◆ BKE_curvemap_remove_point()

bool BKE_curvemap_remove_point ( CurveMap cuma,
CurveMapPoint point 
)

Definition at line 187 of file colortools.c.

References Freestyle::a, CurveMap::curve, MEM_freeN, MEM_mallocN, and CurveMap::totpoint.

◆ BKE_curvemap_reset()

void BKE_curvemap_reset ( CurveMap cuma,
const rctf clipr,
int  preset,
int  slope 
)

◆ BKE_curvemapping_add()

CurveMapping* BKE_curvemapping_add ( int  tot,
float  minx,
float  miny,
float  maxx,
float  maxy 
)

◆ BKE_curvemapping_blend_read()

void BKE_curvemapping_blend_read ( BlendDataReader reader,
CurveMapping cumap 
)

◆ BKE_curvemapping_blend_write()

void BKE_curvemapping_blend_write ( BlendWriter writer,
const CurveMapping cumap 
)

◆ BKE_curvemapping_changed()

void BKE_curvemapping_changed ( CurveMapping cumap,
const bool  rem_doubles 
)

◆ BKE_curvemapping_changed_all()

void BKE_curvemapping_changed_all ( CurveMapping cumap)

◆ BKE_curvemapping_copy()

CurveMapping* BKE_curvemapping_copy ( const CurveMapping cumap)

Definition at line 146 of file colortools.c.

References BKE_curvemapping_copy_data(), MEM_dupallocN, and NULL.

Referenced by BKE_color_managed_view_settings_copy().

◆ BKE_curvemapping_copy_data()

void BKE_curvemapping_copy_data ( CurveMapping target,
const CurveMapping cumap 
)

◆ BKE_curvemapping_curves_blend_write()

void BKE_curvemapping_curves_blend_write ( BlendWriter writer,
const CurveMapping cumap 
)

◆ BKE_curvemapping_evaluate3F()

void BKE_curvemapping_evaluate3F ( const CurveMapping cumap,
float  vecout[3],
const float  vecin[3] 
)

Definition at line 1017 of file colortools.c.

References BKE_curvemap_evaluateF(), and CurveMapping::cm.

◆ BKE_curvemapping_evaluate_premulRGB()

void BKE_curvemapping_evaluate_premulRGB ( const CurveMapping cumap,
unsigned char  vecout_byte[3],
const unsigned char  vecin_byte[3] 
)

◆ BKE_curvemapping_evaluate_premulRGBF()

void BKE_curvemapping_evaluate_premulRGBF ( const CurveMapping cumap,
float  vecout[3],
const float  vecin[3] 
)

◆ BKE_curvemapping_evaluate_premulRGBF_ex()

void BKE_curvemapping_evaluate_premulRGBF_ex ( const CurveMapping cumap,
float  vecout[3],
const float  vecin[3],
const float  black[3],
const float  bwmul[3] 
)

Same as BKE_curvemapping_evaluate_premulRGBF but black/bwmul are passed as args for the compositor where they can change per pixel.

Use in conjunction with BKE_curvemapping_set_black_white_ex

Parameters
blackUse instead of cumap->black
bwmulUse instead of cumap->bwmul

Definition at line 1065 of file colortools.c.

References BKE_curvemap_evaluateF(), CurveMapping::cm, copy_v2_fl2(), CURVE_TONE_FILMLIKE, CURVE_TONE_STANDARD, curvemapping_evaluateRGBF_filmlike(), r, and CurveMapping::tone.

Referenced by BKE_curvemapping_evaluate_premulRGBF().

◆ BKE_curvemapping_evaluateF()

float BKE_curvemapping_evaluateF ( const CurveMapping cumap,
int  cur,
float  value 
)

◆ BKE_curvemapping_evaluateRGBF()

void BKE_curvemapping_evaluateRGBF ( const CurveMapping cumap,
float  vecout[3],
const float  vecin[3] 
)

Definition at line 1025 of file colortools.c.

References BKE_curvemap_evaluateF(), and CurveMapping::cm.

◆ BKE_curvemapping_free()

void BKE_curvemapping_free ( CurveMapping cumap)

◆ BKE_curvemapping_free_data()

void BKE_curvemapping_free_data ( CurveMapping cumap)

◆ BKE_curvemapping_init()

void BKE_curvemapping_init ( CurveMapping cumap)

Definition at line 1200 of file colortools.c.

References Freestyle::a, CurveMapping::cm, CM_TOT, curvemap_make_table(), NULL, and CurveMap::table.

Referenced by BKE_brush_gen_radial_control_imbuf(), BKE_gpencil_brush_preset_set(), BKE_gpencil_modifier_blend_read_data(), BKE_particlesettings_clump_curve_init(), BKE_particlesettings_rough_curve_init(), BKE_particlesettings_twist_curve_init(), blo_do_versions_270(), blo_do_versions_280(), blo_do_versions_290(), blo_do_versions_pre250(), blo_update_defaults_scene(), cloth_brush_apply_brush_foces(), blender::compositor::TimeNode::convertToOperations(), createTransGPencil(), curve_mapping_to_ocio_settings(), curves_apply(), deformVerts_do(), density_falloff(), do_displacement_eraser_brush(), do_displacement_smear_brush(), do_draw_brush(), do_draw_sharp_brush(), do_slide_relax_brush(), ED_gpencil_add_defaults(), Freestyle_evaluateCurveMappingF(), gpencil_init_drawing_brush(), gpencil_interpolate_seq_exec(), gpencil_primitive_update_strokes(), gpencil_sculpt_brush_init(), gpencil_vertexpaint_brush_init(), gpencil_weightpaint_brush_init(), gpu_shader_curve_rgb(), hue_correct_apply(), initData(), blender::compositor::CurveBaseOperation::initExecution(), light_init_data(), load_tex_cursor(), node_initexec_curves(), paint_stroke_new(), paint_weight_gradient_exec(), radial_control_paint_curve(), scene_init_data(), sculpt_boundary_falloff_factor_init(), SCULPT_do_draw_face_sets_brush(), SCULPT_do_paint_brush(), SCULPT_do_smear_brush(), sculpt_expand_cache_initial_config_set(), sculpt_pose_do_translate_deform(), sculpt_pose_do_twist_deform(), sculpt_update_cache_invariants(), time_colorfn(), uv_sculpt_stroke_init(), warpModifier_do(), and weightvg_do_map().

◆ BKE_curvemapping_premultiply()

void BKE_curvemapping_premultiply ( CurveMapping cumap,
int  restore 
)

◆ BKE_curvemapping_reset_view()

void BKE_curvemapping_reset_view ( CurveMapping cumap)

Definition at line 969 of file colortools.c.

References CurveMapping::clipr, and CurveMapping::curr.

Referenced by curvemap_tools_dofunc().

◆ BKE_curvemapping_RGBA_does_something()

bool BKE_curvemapping_RGBA_does_something ( const CurveMapping cumap)

◆ BKE_curvemapping_set_black_white()

void BKE_curvemapping_set_black_white ( CurveMapping cumap,
const float  black[3],
const float  white[3] 
)

◆ BKE_curvemapping_set_black_white_ex()

void BKE_curvemapping_set_black_white_ex ( const float  black[3],
const float  white[3],
float  r_bwmul[3] 
)

◆ BKE_curvemapping_set_defaults()

void BKE_curvemapping_set_defaults ( CurveMapping cumap,
int  tot,
float  minx,
float  miny,
float  maxx,
float  maxy 
)

◆ BKE_curvemapping_table_RGBA()

void BKE_curvemapping_table_RGBA ( const CurveMapping cumap,
float **  array,
int *  size 
)

◆ BKE_histogram_update_sample_line()

void BKE_histogram_update_sample_line ( Histogram hist,
ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ BKE_scopes_free()

void BKE_scopes_free ( Scopes scopes)

Definition at line 1717 of file colortools.c.

References MEM_freeN, NULL, Scopes::vecscope, Scopes::waveform_1, Scopes::waveform_2, and Scopes::waveform_3.

Referenced by image_free().

◆ BKE_scopes_new()

void BKE_scopes_new ( Scopes scopes)

◆ BKE_scopes_update()

void BKE_scopes_update ( Scopes scopes,
ImBuf ibuf,
const ColorManagedViewSettings view_settings,
const ColorManagedDisplaySettings display_settings 
)

◆ calchandle_curvemap()

static void calchandle_curvemap ( BezTriple bezt,
const BezTriple prev,
const BezTriple next 
)
static

◆ curvemap_calc_extend()

static float curvemap_calc_extend ( const CurveMapping cumap,
const CurveMap cuma,
float  x,
const float  first[2],
const float  last[2] 
)
static

◆ curvemap_make_table()

static void curvemap_make_table ( const CurveMapping cumap,
CurveMap cuma 
)
static

◆ curvemapping_evaluateRGBF_filmlike()

static void curvemapping_evaluateRGBF_filmlike ( const CurveMapping cumap,
float  vecout[3],
const float  vecin[3],
const int  channel_offset[3] 
)
static

Definition at line 1037 of file colortools.c.

References BKE_curvemap_evaluateF(), CurveMapping::cm, v1, and v2.

Referenced by BKE_curvemapping_evaluate_premulRGBF_ex().

◆ get_bin_float()

BLI_INLINE int get_bin_float ( float  f)

Definition at line 1268 of file colortools.c.

References CLAMP.

Referenced by scopes_update_cb().

◆ save_sample_line()

static void save_sample_line ( Scopes scopes,
const int  idx,
const float  fx,
const float  rgb[3],
const float  ycc[3] 
)
static

◆ scopes_update_cb()

static void scopes_update_cb ( void *__restrict  userdata,
const int  y,
const TaskParallelTLS *__restrict  tls 
)
static

◆ scopes_update_reduce()

static void scopes_update_reduce ( const void *__restrict   UNUSEDuserdata,
void *__restrict  chunk_join,
void *__restrict  chunk 
)
static

◆ sort_curvepoints()

static int sort_curvepoints ( const void *  a1,
const void *  a2 
)
static

Definition at line 861 of file colortools.c.

References CurveMapPoint::x, and x2.

Referenced by BKE_curvemapping_changed().