void PixelBufferClass::CalcOutput(int EffectPeriod) { wxColour color; wxImage::HSVValue hsv; int curStep, fadeInSteps, fadeOutSteps; double fadeInFactor=1, fadeOutFactor=1; for(int ii=0; ii<2; ii++) { fadeFactor[ii] = 1.0; Effect[ii].GetFadeSteps( fadeInSteps, fadeOutSteps); if( fadeInSteps > 0 || fadeOutSteps > 0) { int effStartPer, effNextPer, effEndPer; Effect[ii].GetEffectPeriods( effStartPer, effNextPer, effEndPer); if (EffectPeriod < (effStartPer)+fadeInSteps) { curStep = EffectPeriod - effStartPer; fadeInFactor = (double)curStep/(double)fadeInSteps; } if (EffectPeriod > (effNextPer)-fadeOutSteps) { curStep = EffectPeriod - (effNextPer-fadeOutSteps); fadeOutFactor = 1-(double)curStep/(double)fadeOutSteps; } if(fadeInFactor < 1 && fadeOutFactor < 1) { fadeFactor[ii] = (fadeInFactor+fadeOutFactor)/(double)2.0; } else if (fadeInFactor<1) { fadeFactor[ii] = fadeInFactor; } else { fadeFactor[ii] = fadeOutFactor; } } } // layer calculation and map to output size_t NodeCount=Nodes.size(); for(size_t i=0; i<NodeCount; i++) { if (!Nodes[i]->IsVisible()) { // unmapped pixel - set to black Nodes[i]->SetColor(0,0,0); } else { // get blend of two effects GetMixedColor(Nodes[i]->Coords[0].bufX, Nodes[i]->Coords[0].bufY, color); // add sparkles if (sparkle_count > 0 && color.GetRGB()!=0) { switch (Nodes[i]->sparkle%sparkle_count) { case 1: case 7: // too dim //color.Set("#444444"); break; case 2: case 6: color.Set("#888888"); break; case 3: case 5: color.Set("#BBBBBB"); break; case 4: color.Set("#FFFFFF"); break; } Nodes[i]->sparkle++; } // Apply brightness wxImage::RGBValue rgb(color.Red(),color.Green(),color.Blue()); hsv = wxImage::RGBtoHSV(rgb); hsv.value = hsv.value * ((double)brightness/(double)100); // Apply Contrast if(hsv.value< 0.5) // reduce brightness when below 0.5 in the V value or increase if > 0.5 { hsv.value = hsv.value - (hsv.value* ((double)contrast/(double)100)); } else { hsv.value = hsv.value + (hsv.value* ((double)contrast/(double)100)); } if(hsv.value < 0.0) hsv.value=0.0; if(hsv.value > 1.0) hsv.value=1.0; rgb = wxImage::HSVtoRGB(hsv); color = wxColor(rgb.red,rgb.green,rgb.blue); // set color for physical output Nodes[i]->SetColor(color); } } }
void PixelBufferClass::CalcOutput(int EffectPeriod) { xlColor color; wxImage::HSVValue hsv; int curStep, fadeInSteps, fadeOutSteps; double fadeInFactor=1, fadeOutFactor=1; for(int ii=0; ii<2; ii++) { fadeFactor[ii] = 1.0; Effect[ii].GetFadeSteps( fadeInSteps, fadeOutSteps); if( fadeInSteps > 0 || fadeOutSteps > 0) { int effStartPer, effNextPer, effEndPer; Effect[ii].GetEffectPeriods( effStartPer, effNextPer, effEndPer); if (EffectPeriod < (effStartPer)+fadeInSteps) { curStep = EffectPeriod - effStartPer; fadeInFactor = (double)curStep/(double)fadeInSteps; } if (EffectPeriod > (effNextPer)-fadeOutSteps) { curStep = EffectPeriod - (effNextPer-fadeOutSteps); fadeOutFactor = 1-(double)curStep/(double)fadeOutSteps; } if(fadeInFactor < 1 && fadeOutFactor < 1) { fadeFactor[ii] = (fadeInFactor+fadeOutFactor)/(double)2.0; } else if (fadeInFactor<1) { fadeFactor[ii] = fadeInFactor; } else { fadeFactor[ii] = fadeOutFactor; } } } // layer calculation and map to output size_t NodeCount=Nodes.size(); for(size_t i=0; i<NodeCount; i++) { if (!Nodes[i]->IsVisible()) { // unmapped pixel - set to black Nodes[i]->SetColor(0,0,0); } else { // get blend of two effects GetMixedColor(Nodes[i]->Coords[0].bufX, Nodes[i]->Coords[0].bufY, color); // add sparkles if (sparkle_count > 0 && color.GetRGB()!=0) { switch (Nodes[i]->sparkle%sparkle_count) { case 1: case 7: // too dim //color.Set("#444444"); break; case 2: case 6: color.Set(0x88, 0x88, 0x88); break; case 3: case 5: color.Set(0xbb, 0xbb, 0xbb); break; case 4: color.Set(255, 255, 255); break; } Nodes[i]->sparkle++; } // Apply brightness wxImage::RGBValue rgb(color.Red(),color.Green(),color.Blue()); //TODO: bypass below hsv conversion if brightness == 100 && contrast == 100? hsv = wxImage::RGBtoHSV(rgb); //ModelBrightness=1.0; // <SCM> we will use this until we figure how to pass in Model brightness //NOTE: ModelBrightness is additive (+/- adjustment), but brightness from effect settings is a multiplier (scaled) float fModelBrightness=((float)ModelBrightness/100) + 1.0; hsv.value = hsv.value * ((double)brightness/(double)100)*fModelBrightness; // Apply Contrast if(hsv.value< 0.5) // reduce brightness when below 0.5 in the V value or increase if > 0.5 { hsv.value = hsv.value - (hsv.value* ((double)contrast/(double)100)); } else { hsv.value = hsv.value + (hsv.value* ((double)contrast/(double)100)); } if(hsv.value < 0.0) hsv.value=0.0; if(hsv.value > 1.0) hsv.value=1.0; rgb = wxImage::HSVtoRGB(hsv); // set color for physical output Nodes[i]->SetColor(rgb.red,rgb.green,rgb.blue); } } }
void PixelBufferClass::CalcOutput(int EffectPeriod, const std::vector<bool> & validLayers) { xlColor color; HSVValue hsv; int curStep; // blur all the layers if necessary ... before the merge? for (int layer = 0; layer < numLayers; layer++) { // do gausian blur if (layers[layer]->blur > 1) { Blur(layers[layer]); } if (layers[layer]->RotoZoom > 0) { RotoZoom(layers[layer]); } } for(int ii=0; ii < numLayers; ii++) { double fadeInFactor=1, fadeOutFactor=1; layers[ii]->fadeFactor = 1.0; layers[ii]->inMaskFactor = 1.0; layers[ii]->outMaskFactor = 1.0; if( layers[ii]->fadeInSteps > 0 || layers[ii]->fadeOutSteps > 0) { int effStartPer, effEndPer; layers[ii]->buffer.GetEffectPeriods( effStartPer, effEndPer); if (EffectPeriod < (effStartPer)+layers[ii]->fadeInSteps) { curStep = EffectPeriod - effStartPer + 1; fadeInFactor = (double)curStep/(double)layers[ii]->fadeInSteps; } if (EffectPeriod > (effEndPer)-layers[ii]->fadeOutSteps) { curStep = EffectPeriod - (effEndPer-layers[ii]->fadeOutSteps); fadeOutFactor = 1-(double)curStep/(double)layers[ii]->fadeOutSteps; } //calc fades if (STR_FADE == layers[ii]->inTransitionType) { if (fadeInFactor<1) { layers[ii]->fadeFactor = fadeInFactor; } } if (STR_FADE == layers[ii]->outTransitionType) { if (fadeOutFactor<1) { if (STR_FADE == layers[ii]->inTransitionType && fadeInFactor<1) { layers[ii]->fadeFactor = (fadeInFactor+fadeOutFactor)/(double)2.0; } else { layers[ii]->fadeFactor = fadeOutFactor; } } } if (STR_FADE != layers[ii]->inTransitionType) { layers[ii]->inMaskFactor = fadeInFactor; } if (STR_FADE != layers[ii]->outTransitionType) { layers[ii]->outMaskFactor = fadeOutFactor; } layers[ii]->calculateMask(); } else { layers[ii]->mask.clear(); } } // layer calculation and map to output size_t NodeCount = layers[0]->Nodes.size(); for(size_t i = 0; i < NodeCount; i++) { if (!layers[0]->Nodes[i]->IsVisible()) { // unmapped pixel - set to black layers[0]->Nodes[i]->SetColor(xlBLACK); } else { // get blend of two effects GetMixedColor(i, color, validLayers); // Apply dimming curve DimmingCurve *curve = layers[0]->Nodes[i]->model->modelDimmingCurve; if (curve != nullptr) { curve->apply(color); } // set color for physical output layers[0]->Nodes[i]->SetColor(color); } } }