Blender  V2.93
BLI_math_color_blend.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  *
19  * The Original Code is: some of this file.
20  */
21 
22 #pragma once
23 
28 #include "BLI_math_inline.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /******************** Blending Modes **********************
35  * - byte function assume straight alpha
36  * - float functions assume premultiplied alpha
37  */
38 
39 MINLINE void blend_color_mix_byte(unsigned char dst[4],
40  const unsigned char src1[4],
41  const unsigned char src2[4]);
42 MINLINE void blend_color_add_byte(unsigned char dst[4],
43  const unsigned char src1[4],
44  const unsigned char src2[4]);
45 MINLINE void blend_color_sub_byte(unsigned char dst[4],
46  const unsigned char src1[4],
47  const unsigned char src2[4]);
48 MINLINE void blend_color_mul_byte(unsigned char dst[4],
49  const unsigned char src1[4],
50  const unsigned char src2[4]);
51 MINLINE void blend_color_lighten_byte(unsigned char dst[4],
52  const unsigned char src1[4],
53  const unsigned char src2[4]);
54 MINLINE void blend_color_darken_byte(unsigned char dst[4],
55  const unsigned char src1[4],
56  const unsigned char src2[4]);
57 MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4],
58  const unsigned char src1[4],
59  const unsigned char src2[4]);
60 MINLINE void blend_color_add_alpha_byte(unsigned char dst[4],
61  const unsigned char src1[4],
62  const unsigned char src2[4]);
63 
64 MINLINE void blend_color_overlay_byte(unsigned char dst[4],
65  const uchar src1[4],
66  const uchar src2[4]);
67 MINLINE void blend_color_hardlight_byte(unsigned char dst[4],
68  const uchar src1[4],
69  const uchar src2[4]);
70 MINLINE void blend_color_burn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4]);
71 MINLINE void blend_color_linearburn_byte(unsigned char dst[4],
72  const uchar src1[4],
73  const uchar src2[4]);
74 MINLINE void blend_color_dodge_byte(unsigned char dst[4],
75  const uchar src1[4],
76  const uchar src2[4]);
77 MINLINE void blend_color_screen_byte(unsigned char dst[4],
78  const uchar src1[4],
79  const uchar src2[4]);
80 MINLINE void blend_color_softlight_byte(unsigned char dst[4],
81  const uchar src1[4],
82  const uchar src2[4]);
83 MINLINE void blend_color_pinlight_byte(unsigned char dst[4],
84  const uchar src1[4],
85  const uchar src2[4]);
86 MINLINE void blend_color_linearlight_byte(unsigned char dst[4],
87  const uchar src1[4],
88  const uchar src2[4]);
89 MINLINE void blend_color_vividlight_byte(unsigned char dst[4],
90  const uchar src1[4],
91  const uchar src2[4]);
92 MINLINE void blend_color_difference_byte(unsigned char dst[4],
93  const uchar src1[4],
94  const uchar src2[4]);
95 MINLINE void blend_color_exclusion_byte(unsigned char dst[4],
96  const uchar src1[4],
97  const uchar src2[4]);
98 MINLINE void blend_color_color_byte(unsigned char dst[4],
99  const uchar src1[4],
100  const uchar src2[4]);
101 MINLINE void blend_color_hue_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4]);
102 MINLINE void blend_color_saturation_byte(unsigned char dst[4],
103  const uchar src1[4],
104  const uchar src2[4]);
105 MINLINE void blend_color_luminosity_byte(unsigned char dst[4],
106  const uchar src1[4],
107  const uchar src2[4]);
108 
109 MINLINE void blend_color_interpolate_byte(unsigned char dst[4],
110  const unsigned char src1[4],
111  const unsigned char src2[4],
112  float t);
113 
114 MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4]);
115 MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4]);
116 MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4]);
117 MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4]);
118 MINLINE void blend_color_lighten_float(float dst[4], const float src1[4], const float src2[4]);
119 MINLINE void blend_color_darken_float(float dst[4], const float src1[4], const float src2[4]);
120 MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4]);
121 MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], const float src2[4]);
122 
123 MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4]);
124 MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4]);
125 MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4]);
126 MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float src2[4]);
127 MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4]);
128 MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const float src2[4]);
129 MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], const float src2[4]);
130 MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const float src2[4]);
131 MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4]);
132 MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], const float src2[4]);
133 MINLINE void blend_color_difference_float(float dst[4], const float src1[4], const float src2[4]);
134 MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4]);
135 MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4]);
136 MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const float src2[4]);
137 MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], const float src2[4]);
138 MINLINE void blend_color_luminosity_float(float dst[4], const float src1[4], const float src2[4]);
139 
140 MINLINE void blend_color_interpolate_float(float dst[4],
141  const float src1[4],
142  const float src2[4],
143  float t);
144 
145 #if BLI_MATH_DO_INLINE
147 #endif
148 
149 #ifdef __cplusplus
150 }
151 #endif
MINLINE void blend_color_add_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_exclusion_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearburn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_overlay_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_saturation_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_interpolate_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4], float t)
MINLINE void blend_color_burn_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_erase_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_color_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_sub_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_saturation_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_hue_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_difference_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_dodge_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_luminosity_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_pinlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mul_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_pinlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_erase_alpha_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_screen_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_screen_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_add_alpha_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_vividlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_linearburn_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_mul_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_vividlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_darken_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_mix_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_luminosity_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_difference_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_burn_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_add_alpha_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_color_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_overlay_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_dodge_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_hardlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_sub_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_darken_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_softlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_add_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_hue_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_lighten_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_exclusion_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_mix_byte(unsigned char dst[4], const unsigned char src1[4], const unsigned char src2[4])
MINLINE void blend_color_hardlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_linearlight_byte(unsigned char dst[4], const uchar src1[4], const uchar src2[4])
MINLINE void blend_color_lighten_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_softlight_float(float dst[4], const float src1[4], const float src2[4])
MINLINE void blend_color_interpolate_float(float dst[4], const float src1[4], const float src2[4], float t)
#define MINLINE
unsigned char uchar
Definition: BLI_sys_types.h:86
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble t