|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "stdfx.h"
|
|
Toshihiro Shimizu |
890ddd |
//#include "tsystem.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tfxparam.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tpixelutils.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tparamset.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "trop.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//===================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class AdjustLevelsFx : public TStandardRasterFx
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_DECLARATION(AdjustLevelsFx)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterFxPort m_input;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_in_rgb;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_in_r;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_in_g;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_in_b;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_in_m;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_out_rgb;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_out_r;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_out_g;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_out_b;
|
|
Toshihiro Shimizu |
890ddd |
TRangeParamP m_out_m;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_gamma_rgb;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_gamma_r;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_gamma_g;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_gamma_b;
|
|
Toshihiro Shimizu |
890ddd |
TDoubleParamP m_gamma_m;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
AdjustLevelsFx()
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
: m_in_rgb(DoublePair(0.0, 255.0)), m_in_r(DoublePair(0.0, 255.0)), m_in_g(DoublePair(0.0, 255.0)), m_in_b(DoublePair(0.0, 255.0)), m_in_m(DoublePair(0.0, 255.0)), m_out_rgb(DoublePair(0.0, 255.0)), m_out_r(DoublePair(0.0, 255.0)), m_out_g(DoublePair(0.0, 255.0)), m_out_b(DoublePair(0.0, 255.0)), m_out_m(DoublePair(0.0, 255.0)), m_gamma_rgb(1.0), m_gamma_r(1.0), m_gamma_g(1.0), m_gamma_b(1.0), m_gamma_m(1.0)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "in_rgb", m_in_rgb);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "in_r", m_in_r);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "in_g", m_in_g);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "in_b", m_in_b);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "in_m", m_in_m);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "out_rgb", m_out_rgb);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "out_r", m_out_r);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "out_g", m_out_g);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "out_b", m_out_b);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "out_m", m_out_m);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "gamma_rgb", m_gamma_rgb);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "gamma_r", m_gamma_r);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "gamma_g", m_gamma_g);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "gamma_b", m_gamma_b);
|
|
Toshihiro Shimizu |
890ddd |
bindParam(this, "gamma_m", m_gamma_m);
|
|
Toshihiro Shimizu |
890ddd |
addInputPort("Source", m_input);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_in_rgb->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_rgb->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_r->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_r->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_g->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_g->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_b->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_b->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_m->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_in_m->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_rgb->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_rgb->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_r->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_r->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_g->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_g->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_b->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_b->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_m->getMin()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_out_m->getMax()->setValueRange(0, 255);
|
|
Toshihiro Shimizu |
890ddd |
m_gamma_rgb->setValueRange(0.0, 200.0);
|
|
Toshihiro Shimizu |
890ddd |
m_gamma_r->setValueRange(0.0, 200.0);
|
|
Toshihiro Shimizu |
890ddd |
m_gamma_g->setValueRange(0.0, 200.0);
|
|
Toshihiro Shimizu |
890ddd |
m_gamma_b->setValueRange(0.0, 200.0);
|
|
Toshihiro Shimizu |
890ddd |
m_gamma_m->setValueRange(0.0, 200.0);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~AdjustLevelsFx(){};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool canHandle(const TRenderSettings &info, double frame) { return true; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
bool doGetBBox(double frame, TRectD &bBox, const TRenderSettings &info)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (m_input.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return m_input->doGetBBox(frame, bBox, info);
|
|
Toshihiro Shimizu |
890ddd |
else {
|
|
Toshihiro Shimizu |
890ddd |
bBox = TRectD();
|
|
Toshihiro Shimizu |
890ddd |
return false;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void doCompute(TTile &tile, double frame, const TRenderSettings &ri);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void AdjustLevelsFx::doCompute(TTile &tile, double frame, const TRenderSettings &ri)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
if (!m_input.isConnected())
|
|
Toshihiro Shimizu |
890ddd |
return;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
m_input->compute(tile, frame, ri);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double gamma_rgb = m_gamma_rgb->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double gamma_r = m_gamma_r->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double gamma_g = m_gamma_g->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double gamma_b = m_gamma_b->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
double gamma_m = m_gamma_m->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vin_rgb = m_in_rgb->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vin_r = m_in_r->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vin_g = m_in_g->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vin_b = m_in_b->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vin_m = m_in_m->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vout_rgb = m_out_rgb->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vout_r = m_out_r->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vout_g = m_out_g->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vout_b = m_out_b->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
DoublePair vout_m = m_out_m->getValue(frame);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int in0[5], in1[5], out0[5], out1[5];
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
in0[0] = vin_rgb.first, in1[0] = vin_rgb.second;
|
|
Toshihiro Shimizu |
890ddd |
out0[0] = vout_rgb.first, out1[0] = vout_rgb.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
in0[1] = vin_r.first, in1[1] = vin_r.second;
|
|
Toshihiro Shimizu |
890ddd |
out0[1] = vout_r.first, out1[1] = vout_r.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
in0[2] = vin_g.first, in1[2] = vin_g.second;
|
|
Toshihiro Shimizu |
890ddd |
out0[2] = vout_g.first, out1[2] = vout_g.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
in0[3] = vin_b.first, in1[3] = vin_b.second;
|
|
Toshihiro Shimizu |
890ddd |
out0[3] = vout_b.first, out1[3] = vout_b.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
in0[4] = vin_m.first, in1[4] = vin_m.second;
|
|
Toshihiro Shimizu |
890ddd |
out0[4] = vout_m.first, out1[4] = vout_m.second;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRasterP ras = tile.getRaster();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
TRop::rgbmAdjust(ras, ras, in0, in1, out0, out1);
|
|
Toshihiro Shimizu |
890ddd |
TRop::gammaCorrect(ras, gamma_rgb);
|
|
Toshihiro Shimizu |
890ddd |
TRop::gammaCorrectRGBM(ras, gamma_r, gamma_g, gamma_b, gamma_m);
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
FX_PLUGIN_IDENTIFIER(AdjustLevelsFx, "adjustLevelsFx");
|