/* === S Y N F I G ========================================================= */
/*! \file colorcorrect.cpp
-** \brief Template Header
+** \brief Implementation of the "Color Correct" layer
**
-** $Id: colorcorrect.cpp,v 1.3 2005/01/24 05:00:18 darco Exp $
+** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
SYNFIG_LAYER_INIT(Layer_ColorCorrect);
SYNFIG_LAYER_SET_NAME(Layer_ColorCorrect,"colorcorrect");
-SYNFIG_LAYER_SET_LOCAL_NAME(Layer_ColorCorrect,_("Color Correct"));
-SYNFIG_LAYER_SET_CATEGORY(Layer_ColorCorrect,_("Filters"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Layer_ColorCorrect,N_("Color Correct"));
+SYNFIG_LAYER_SET_CATEGORY(Layer_ColorCorrect,N_("Filters"));
SYNFIG_LAYER_SET_VERSION(Layer_ColorCorrect,"0.1");
-SYNFIG_LAYER_SET_CVS_ID(Layer_ColorCorrect,"$Id: colorcorrect.cpp,v 1.3 2005/01/24 05:00:18 darco Exp $");
+SYNFIG_LAYER_SET_CVS_ID(Layer_ColorCorrect,"$Id$");
/* === P R O C E D U R E S ================================================= */
{
Color ret(in);
Real brightness((this->brightness-0.5)*this->contrast+0.5);
-
+
if(gamma.get_gamma_r()!=1.0)
{
if(ret.get_r() < 0)
ret.set_r(-gamma.r_F32_to_F32(-ret.get_r()));
}else
{
- ret.set_r(gamma.r_F32_to_F32(ret.get_r()));
- }
+ ret.set_r(gamma.r_F32_to_F32(ret.get_r()));
+ }
}
if(gamma.get_gamma_g()!=1.0)
{
ret.set_g(-gamma.g_F32_to_F32(-ret.get_g()));
}else
{
- ret.set_g(gamma.g_F32_to_F32(ret.get_g()));
- }
+ ret.set_g(gamma.g_F32_to_F32(ret.get_g()));
+ }
}
if(gamma.get_gamma_b()!=1.0)
{
ret.set_b(-gamma.b_F32_to_F32(-ret.get_b()));
}else
{
- ret.set_b(gamma.b_F32_to_F32(ret.get_b()));
- }
+ ret.set_b(gamma.b_F32_to_F32(ret.get_b()));
+ }
}
-
+
assert(!isnan(ret.get_r()));
assert(!isnan(ret.get_g()));
assert(!isnan(ret.get_b()));
-
+
if(exposure!=0.0)
{
const float factor(exp(exposure));
ret.set_g(ret.get_g()*factor);
ret.set_b(ret.get_b()*factor);
}
-
+
// Adjust Contrast
if(contrast!=1.0)
{
ret.set_g(ret.get_g()*contrast);
ret.set_b(ret.get_b()*contrast);
}
-
+
if(brightness)
{
// Adjust R Channel Brightness
ret.set_r(ret.get_r()-brightness);
else
ret.set_r(0);
-
+
// Adjust G Channel Brightness
if(ret.get_g()>-brightness)
ret.set_g(ret.get_g()+brightness);
ret.set_g(ret.get_g()-brightness);
else
ret.set_g(0);
-
+
// Adjust B Channel Brightness
if(ret.get_b()>-brightness)
ret.set_b(ret.get_b()+brightness);
else
ret.set_b(0);
}
-
+
// Return the color, adjusting the hue if necessary
if(!!hue_adjust)
return ret.rotate_uv(hue_adjust);
else
return ret;
}
-
+
bool
Layer_ColorCorrect::set_param(const String & param, const ValueBase &value)
{
{
gamma.set_gamma(1.0/value.get(Real()));
return true;
- }
- return false;
+ }
+ return false;
}
ValueBase
EXPORT_NAME();
EXPORT_VERSION();
-
- return ValueBase();
+
+ return ValueBase();
}
Layer::Vocab
Layer_ColorCorrect::get_param_vocab()const
{
Layer::Vocab ret;
-
+
ret.push_back(ParamDesc("hue_adjust")
.set_local_name(_("Hue Adjust"))
);
ret.push_back(ParamDesc("gamma")
.set_local_name(_("Gamma Adjustment"))
);
-
+
return ret;
}
{
return correct_color(context.get_color(pos));
}
-
+
bool
Layer_ColorCorrect::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const
{