tahoma2d/toonz/sources/stdfx/gammafx.cpp

56 lines
1.3 KiB
C++
Raw Normal View History

2016-03-19 06:57:51 +13:00
#include "stdfx.h"
#include "tfxparam.h"
#include "trop.h"
class GammaFx final : public TStandardRasterFx {
2016-06-15 18:43:10 +12:00
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(){};
2016-06-20 14:23:05 +12:00
bool doGetBBox(double frame, TRectD &bBox,
const TRenderSettings &info) override {
2016-06-15 18:43:10 +12:00
if (m_input.isConnected())
return m_input->doGetBBox(frame, bBox, info);
else {
bBox = TRectD();
return false;
}
};
2016-06-19 20:06:29 +12:00
void doCompute(TTile &tile, double frame, const TRenderSettings &) override;
2016-06-15 18:43:10 +12:00
2016-06-20 14:23:05 +12:00
bool canHandle(const TRenderSettings &info, double frame) override {
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")