MCPcopy Create free account
hub / github.com/Atarity/Lightpack / handleGrabbedColors

Method handleGrabbedColors

Software/src/GrabManager.cpp:283–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void GrabManager::handleGrabbedColors()
284{
285 DEBUG_MID_LEVEL << Q_FUNC_INFO;
286
287 if (m_grabber == NULL)
288 {
289 qCritical() << Q_FUNC_INFO << "m_grabber == NULL";
290 return;
291 }
292
293 // Temporary switch off updating colors
294 // if one of LED widgets resizing or moving
295 if (m_isPauseGrabWhileResizeOrMoving)
296 {
297 m_timerGrab->start(50); // check in 50 ms
298 return;
299 }
300
301 bool isColorsChanged = false;
302
303 int avgR = 0, avgG = 0, avgB = 0;
304 int countGrabEnabled = 0;
305
306 if (m_avgColorsOnAllLeds)
307 {
308 for (int i = 0; i < m_ledWidgets.size(); i++)
309 {
310 if (m_ledWidgets[i]->isAreaEnabled())
311 {
312 avgR += qRed(m_colorsNew[i]);
313 avgG += qGreen(m_colorsNew[i]);
314 avgB += qBlue(m_colorsNew[i]);
315 countGrabEnabled++;
316 }
317 }
318 if (countGrabEnabled != 0)
319 {
320 avgR /= countGrabEnabled;
321 avgG /= countGrabEnabled;
322 avgB /= countGrabEnabled;
323 }
324 // Set one AVG color to all LEDs
325 for (int ledIndex = 0; ledIndex < m_ledWidgets.size(); ledIndex++)
326 {
327 if (m_ledWidgets[ledIndex]->isAreaEnabled())
328 {
329 m_colorsNew[ledIndex] = qRgb(avgR, avgG, avgB);
330 }
331 }
332 }
333
334// // White balance
335// for (int i = 0; i < m_ledWidgets.size(); i++)
336// {
337// QRgb rgb = m_colorsNew[i];
338
339// unsigned r = qRed(rgb) * m_ledWidgets[i]->getCoefRed();
340// unsigned g = qGreen(rgb) * m_ledWidgets[i]->getCoefGreen();

Callers

nothing calls this directly

Calls 4

howLongItEndMethod · 0.80
howLongItStartMethod · 0.80
startMethod · 0.45
isAreaEnabledMethod · 0.45

Tested by

no test coverage detected