Blender
V5.0
source
blender
imbuf
intern
imageprocess.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2
* SPDX-FileCopyrightText: 2024 Blender Authors
3
*
4
* SPDX-License-Identifier: GPL-2.0-or-later */
5
9
10
#include "
BLI_math_vector.h
"
11
#include "
BLI_task.hh
"
12
13
#include "
IMB_imbuf.hh
"
14
#include "
IMB_imbuf_types.hh
"
15
16
/* -------------------------------------------------------------------- */
19
20
void
IMB_alpha_under_color_float
(
float
*rect_float,
int
x
,
int
y
,
float
backcol[3])
21
{
22
using namespace
blender
;
23
threading::parallel_for
(
IndexRange
(
int64_t
(
x
) *
y
), 32 * 1024, [&](
const
IndexRange
i_range) {
24
float
*pix = rect_float + i_range.
first
() * 4;
25
for
([[maybe_unused]]
const
int
i
: i_range) {
26
const
float
mul
= 1.0f - pix[3];
27
madd_v3_v3fl
(pix, backcol,
mul
);
28
pix[3] = 1.0f;
29
pix += 4;
30
}
31
});
32
}
33
34
void
IMB_alpha_under_color_byte
(
uchar
*rect,
int
x
,
int
y
,
const
float
backcol[3])
35
{
36
using namespace
blender
;
37
threading::parallel_for
(
IndexRange
(
int64_t
(
x
) *
y
), 32 * 1024, [&](
const
IndexRange
i_range) {
38
uchar
*pix = rect + i_range.
first
() * 4;
39
for
([[maybe_unused]]
const
int
i
: i_range) {
40
if
(pix[3] == 255) {
41
/* pass */
42
}
43
else
if
(pix[3] == 0) {
44
pix[0] = backcol[0] * 255;
45
pix[1] = backcol[1] * 255;
46
pix[2] = backcol[2] * 255;
47
}
48
else
{
49
float
alpha = pix[3] / 255.0;
50
float
mul
= 1.0f - alpha;
51
52
pix[0] = (pix[0] * alpha) +
mul
* backcol[0];
53
pix[1] = (pix[1] * alpha) +
mul
* backcol[1];
54
pix[2] = (pix[2] * alpha) +
mul
* backcol[2];
55
}
56
pix[3] = 255;
57
pix += 4;
58
}
59
});
60
}
61
x
x
Definition
BLI_expr_pylike_eval_test.cc:345
BLI_math_vector.h
madd_v3_v3fl
MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f)
Definition
math_vector_inline.cc:494
uchar
unsigned char uchar
Definition
BLI_sys_types.h:67
BLI_task.hh
IMB_imbuf.hh
IMB_imbuf_types.hh
int64_t
long long int int64_t
Definition
btConvexHullComputer.cpp:31
mul
static void mul(btAlignedObjectArray< T > &items, const Q &value)
Definition
btSoftBodyHelpers.cpp:120
IndexRange
Definition
BLI_index_range.hh:50
IndexRange::first
constexpr int64_t first() const
Definition
BLI_index_range.hh:200
y
y
Definition
compositor_morphological_blur_infos.hh:22
IMB_alpha_under_color_byte
void IMB_alpha_under_color_byte(uchar *rect, int x, int y, const float backcol[3])
Definition
imageprocess.cc:34
IMB_alpha_under_color_float
void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3])
Definition
imageprocess.cc:20
blender::threading::parallel_for
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
Definition
BLI_task.hh:93
blender
Definition
ANIM_action.hh:36
i
i
Definition
text_draw.cc:230
Generated on
for Blender by
doxygen
1.16.1