MCPcopy Create free account
hub / github.com/carbonengine/trinity / PyGetKelvinTemperatureBuffer

Function PyGetKelvinTemperatureBuffer

trinity/Tr2KelvinColor_Blue.cpp:99–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99static PyObject* PyGetKelvinTemperatureBuffer( PyObject* self, PyObject* args )
100{
101 int width, height;
102 int intWhiteBalance;
103 if( !PyArg_ParseTuple( args, "iii", &width, &height, &intWhiteBalance ) )
104 {
105 return NULL;
106 }
107
108 Tr2StandardIlluminant stdIllum = (Tr2StandardIlluminant)intWhiteBalance;
109 char* buffer = CCP_NEW( "PyGetKelvinTemperatureBuffer" ) char[3 * width * height];
110
111 const float startK = MIN_KELVIN;
112 const float deltaK = ( MAX_KELVIN - MIN_KELVIN ) / ( static_cast<float>( width ) - 1.0f );
113 float curK = startK;
114
115 // Render one row of the bitmap
116 char* ptr = buffer;
117 for( int i = 0; i < width; ++i )
118 {
119 Vector3d rgb = TriColorFromKelvin( curK, 0.5f, stdIllum );
120 ptr[3 * i] = static_cast<char>( rgb.x * 255.0 );
121 ptr[3 * i + 1] = static_cast<char>( rgb.y * 255.0 );
122 ptr[3 * i + 2] = static_cast<char>( rgb.z * 255.0 );
123 curK += deltaK;
124 }
125
126 // Copy the row into the rest of the buffer
127 for( int i = 1; i < height; ++i )
128 {
129 memcpy( buffer + i * 3 * width, buffer, 3 * width );
130 }
131
132 PyObject* ret = NULL;
133 ret = PyByteArray_FromStringAndSize( buffer, 3 * width * height );
134 CCP_DELETE[] buffer;
135 return ret;
136}
137
138static PyObject* PyGetKelvinTintBuffer( PyObject* self, PyObject* args )
139{

Callers

nothing calls this directly

Calls 1

TriColorFromKelvinFunction · 0.85

Tested by

no test coverage detected