forked from ambilight-4-mediaportal/AtmoWin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtmoBasicEffect.cpp
More file actions
99 lines (79 loc) · 3.19 KB
/
Copy pathAtmoBasicEffect.cpp
File metadata and controls
99 lines (79 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* AtmoBasicEffect.cpp: base class for the fun effects like the ColorChangers....
*
* See the README.txt file for copyright information and how to reach the author(s).
*
* $Id$
*/
#include "StdAfx.h"
#include "atmobasiceffect.h"
#include "AtmoTools.h"
CAtmoBasicEffect::CAtmoBasicEffect(CAtmoConnection *atmoConnection, CAtmoConfig *atmoConfig) : CThread() {
this->m_AtmoConnection = atmoConnection;
this->m_AtmoConfig = atmoConfig;
m_RGB_alt = NULL;
}
CAtmoBasicEffect::~CAtmoBasicEffect(void)
{
delete (char *)m_RGB_alt;
}
void CAtmoBasicEffect::Interpolation(int iSteps, int iPause, pColorPacket fadeTo)
{
int s_1; // zählvariablen
int s_2;
pColorPacket ausgabe;
pColorPacket output;
// Stepsize for each fading step
float *interpolation_r = new float[fadeTo->numColors]; // Differenz zw. 2 R/G/B werten zur Interpolation
float *interpolation_g = new float[fadeTo->numColors];
float *interpolation_b = new float[fadeTo->numColors];
if(!m_RGB_alt || (m_RGB_alt->numColors != fadeTo->numColors) )
{
delete (char *)m_RGB_alt;
m_RGB_alt=NULL;
for ( s_1 = 0; s_1 < fadeTo->numColors ; s_1++ ) {
interpolation_r[s_1] = (float)(fadeTo->zone[s_1].r) / (float)iSteps;
interpolation_g[s_1] = (float)(fadeTo->zone[s_1].g) / (float)iSteps;
interpolation_b[s_1] = (float)(fadeTo->zone[s_1].b) / (float)iSteps;
}
} else {
for ( s_1 = 0; s_1 < fadeTo->numColors ; s_1++ ) {
interpolation_r[s_1] = (float)(fadeTo->zone[s_1].r - m_RGB_alt->zone[s_1].r) / (float)iSteps;
interpolation_g[s_1] = (float)(fadeTo->zone[s_1].g - m_RGB_alt->zone[s_1].g) / (float)iSteps;
interpolation_b[s_1] = (float)(fadeTo->zone[s_1].b - m_RGB_alt->zone[s_1].b) / (float)iSteps;
}
}
AllocColorPacket(ausgabe, fadeTo->numColors);
// fading... color...
for ( s_2 = 1; s_2<=iSteps ; s_2++ ) // anfang interpolation und ausgabe
{
if(m_RGB_alt)
{
for(int zone = 0; zone<fadeTo->numColors; zone++) {
ausgabe->zone[zone].r = m_RGB_alt->zone[zone].r + (int)((float)s_2 * interpolation_r[zone]);
ausgabe->zone[zone].g = m_RGB_alt->zone[zone].g + (int)((float)s_2 * interpolation_g[zone]);
ausgabe->zone[zone].b = m_RGB_alt->zone[zone].b + (int)((float)s_2 * interpolation_b[zone]);
}
} else {
for(int zone = 0; zone<fadeTo->numColors; zone++) {
ausgabe->zone[zone].r = (int)((float)s_2 * interpolation_r[zone]);
ausgabe->zone[zone].g = (int)((float)s_2 * interpolation_g[zone]);
ausgabe->zone[zone].b = (int)((float)s_2 * interpolation_b[zone]);
}
}
DupColorPacket(output, ausgabe);
output = CAtmoTools::ApplyGamma(m_AtmoConfig, output);
if(m_AtmoConfig->isUseSoftwareWhiteAdj())
output = CAtmoTools::WhiteCalibration(m_AtmoConfig, output);
m_AtmoConnection->SendData(output);
delete (char *)output;
if(ThreadSleep(iPause) == ATMO_FALSE)
break;
}
// save last color as start color for next run
delete (char *)m_RGB_alt;
delete []interpolation_r;
delete []interpolation_g;
delete []interpolation_b;
m_RGB_alt = ausgabe;
}