//-------------------------------------------------------------- void testApp::update(){ _movie.idleMovie(); const ofPixelsRef pixels= _movie.getPixelsRef(); long double reds= 0.0; long double blues= 0.0; long double greens= 0.0; for (int x= 0; x < _movie.width; ++x) { for (int y= 0; y < _movie.height; ++y) { reds += pixels.getColor(x, y).r; greens += pixels.getColor(x, y).g; blues += pixels.getColor(x, y).b; } } // Divide by 10 because ofColor rgb values are in units of 0-1000. // // Then we multiply by 2.55 to get us on DMX scale and not percentage avg_red= int(reds/color_pixels*multiplier)/10*2.55; avg_green= int(greens/color_pixels*multiplier)/10*2.55; avg_blue= int(blues/color_pixels*multiplier)/10*2.55; _dmx.SetChannel(0, avg_red); _dmx.SetChannel(1, avg_green); _dmx.SetChannel(2, avg_blue); }
//-------------------------------------------------------------- void scene02::applyLUT(ofPixelsRef pix){ if (LUTloaded) { for(int y = 0; y < pix.getHeight(); y++){ for(int x = 0; x < pix.getWidth(); x++){ ofColor color = pix.getColor(x, y); int lutPos [3]; for (int m=0; m<3; m++) { lutPos[m] = color[m] / 8; if (lutPos[m]==31) { lutPos[m]=30; } } ofVec3f start = lut[lutPos[0]][lutPos[1]][lutPos[2]]; ofVec3f end = lut[lutPos[0]+1][lutPos[1]+1][lutPos[2]+1]; for (int k=0; k<3; k++) { float amount = (color[k] % 8) / 8.0f; color[k]= (start[k] + amount * (end[k] - start[k])) * 255; } lutImg.setColor(x, y, color); } } lutImg.update(); } }
//-------------------------------------------------------------- void LedMatrix::grabImageData(ofPixelsRef pixels) { for (unsigned int i = 0; i < pos.size(); i++) { colors[i] = pixels.getColor(pos[i].x, pos[i].y); } }
void LaserGroup::setPixelsColors(ofPixelsRef pixels) { for(auto laser: m_lasers) { const ofPoint& pos = laser->getPosition(); ofColor color = pixels.getColor(pos.x*pixels.getWidth(), pos.y*pixels.getHeight()); laser->setColor(color); } this->updateColor(); }