tahoma2d/toonz/sources/stdfx/gammafx.cpp

53 lines
1.2 KiB
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "stdfx.h"
#include "tfxparam.h"
#include "trop.h"
2016-06-15 18:43:10 +12:00
class GammaFx : public TStandardRasterFx {
FX_PLUGIN_DECLARATION(GammaFx)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TRasterFxPort m_input;
TDoubleParamP m_gamma;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
GammaFx() : m_gamma(1.0) {
bindParam(this, "value", m_gamma);
addInputPort("Source", m_input);
// m_gamma->setValueRange(0, std::numeric_limits<double>::max());
m_gamma->setValueRange(0.0, 200.0);
}
~GammaFx(){};
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info) {
if (m_input.isConnected())
return m_input->doGetBBox(frame, bBox, info);
else {
bBox = TRectD();
return false;
}
};
void doCompute(TTile &tile, double frame, const TRenderSettings &);
bool canHandle(const TRenderSettings &info, double frame) { return true; }
2016-03-19 06:57:51 +13:00
};
//-------------------------------------------------------------------
2016-06-15 18:43:10 +12:00
void GammaFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri) {
if (!m_input.isConnected()) return;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
m_input->compute(tile, frame, ri);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
double gamma = m_gamma->getValue(frame);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
if (gamma == 0.0) gamma = 0.01;
TRop::gammaCorrect(tile.getRaster(), gamma);
2016-03-19 06:57:51 +13:00
}
//------------------------------------------------------------------
FX_PLUGIN_IDENTIFIER(GammaFx, "gammaFx")