Debian Codegraph @

src/mixer2/blend/blend.cpp

raw symbols SCIP
1 /* blend.cpp
2 * Copyright (C) 2006 Jean-Sebastien Senecal ([email protected])
3 * This file is a Frei0r plugin.
4 * The code is a modified version of code from the Gimp.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "frei0r.hpp"cxx . . $ `<file>/include/frei0r.hpp`/
22 #include "frei0r/math.h"cxx . . $ `<file>/include/frei0r/math.h`/
23
24 #define NBYTEScxx . . $ `src/mixer2/blend/blend.cpp:24:9`! 4
25 #define ALPHAcxx . . $ `src/mixer2/blend/blend.cpp:25:9`! 3
26
27 class blendcxx . . $ blend# : public frei0rcxx . . $ frei0r/::mixer2cxx . . $ frei0r/mixer2#
28 {
29 public:
30 blendcxx . . $ blend#blend(b4d55b1286ff73e8).(unsigned int width, unsigned int height)
31 {
32 this->widthcxx . . $ frei0r/fx#width. = width;
33 this->heightcxx . . $ frei0r/fx#height. = height;
34 this->sizecxx . . $ frei0r/fx#size. = width * height;
35 blend_factorcxx . . $ blend#blend_factor. = 0.5;
36 register_paramcxx . . $ frei0r/fx#register_param(acfd1d4411be0164).(blend_factorcxx . . $ blend#blend_factor.,"blend"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,"blend factor"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).);
37 }
38
39 /**
40 *
41 * Perform a blend operation between sources in1 and in2, using
42 * the generalised algorithm: D = A * (255 - &beta;) + B * &beta;
43 *
44 * The result is left in out
45 **/
46 void updatecxx . . $ blend#update(aea6c563decfb03a).(double time,
47 uint32_t* out,
48 const uint32_t* in1,
49 const uint32_t* in2)
50 {
51 // Validate inputs
52 if (!out || !in1 || !in2) {
53 return;
54 }
55
56 const uint8_t *src1 = reinterpret_cast<const uint8_t*>(in1);
57 const uint8_t *src2 = reinterpret_cast<const uint8_t*>(in2);
58 uint8_t *dst = reinterpret_cast<uint8_t*>(out);
59 const uint8_t bf = (const uint8_t) (255 * blend_factorcxx . . $ blend#blend_factor.);
60 const uint8_t one_minus_bf = (255 - bf);
61 uint32_t w = sizecxx . . $ frei0r/fx#size.;
62 uint32_t b;
63
64 // Validate size
65 if (w == 0) {
66 return;
67 }
68
69 while (w--)
70 {
71 for (b = 0; b < NBYTEScxx . . $ `src/mixer2/blend/blend.cpp:24:9`!; b++)
72 dst[b] = (src1[b] * one_minus_bf + src2[b] * bf) / 255;
73
74 src1 += NBYTEScxx . . $ `src/mixer2/blend/blend.cpp:24:9`!;
75 src2 += NBYTEScxx . . $ `src/mixer2/blend/blend.cpp:24:9`!;
76 dst += NBYTEScxx . . $ `src/mixer2/blend/blend.cpp:24:9`!;
77 }
78 }
79
80 private:
81 double blend_factorcxx . . $ blend#blend_factor.;
82
83 };
84
85
86 frei0rcxx . . $ frei0r/::constructcxx . . $ frei0r/construct#<blendcxx . . $ blend#> plugincxx . . $ plugin.("blend"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
87 "Perform a blend operation between two sources"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
88 "Jean-Sebastien Senecal"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).,
89 0,2,
90 F0R_COLOR_MODEL_RGBA8888cxx . . $ `include/frei0r.h:308:9`!);
91