X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_filter%2Fcolorcorrect.cpp;h=3a0468e253bc9fe607233b605221b2877763b16a;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=83790e2b29cd96bbc4892e1919c4a490a3daad72;hpb=28f28705612902c15cd0702cc891fba35bf2d2df;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_filter/colorcorrect.cpp b/synfig-core/trunk/src/modules/mod_filter/colorcorrect.cpp index 83790e2..3a0468e 100644 --- a/synfig-core/trunk/src/modules/mod_filter/colorcorrect.cpp +++ b/synfig-core/trunk/src/modules/mod_filter/colorcorrect.cpp @@ -1,20 +1,21 @@ /* === 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 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -50,10 +51,10 @@ using namespace synfig; 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 ================================================= */ @@ -74,7 +75,7 @@ Layer_ColorCorrect::correct_color(const Color &in)const { 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) @@ -82,8 +83,8 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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) { @@ -92,8 +93,8 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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) { @@ -102,14 +103,14 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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)); @@ -117,7 +118,7 @@ Layer_ColorCorrect::correct_color(const Color &in)const ret.set_g(ret.get_g()*factor); ret.set_b(ret.get_b()*factor); } - + // Adjust Contrast if(contrast!=1.0) { @@ -125,7 +126,7 @@ Layer_ColorCorrect::correct_color(const Color &in)const ret.set_g(ret.get_g()*contrast); ret.set_b(ret.get_b()*contrast); } - + if(brightness) { // Adjust R Channel Brightness @@ -135,7 +136,7 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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); @@ -143,7 +144,7 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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); @@ -152,14 +153,14 @@ Layer_ColorCorrect::correct_color(const Color &in)const 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) { @@ -172,8 +173,8 @@ 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 @@ -189,15 +190,15 @@ Layer_ColorCorrect::get_param(const String ¶m)const 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")) ); @@ -217,7 +218,7 @@ Layer_ColorCorrect::get_param_vocab()const ret.push_back(ParamDesc("gamma") .set_local_name(_("Gamma Adjustment")) ); - + return ret; } @@ -226,7 +227,7 @@ Layer_ColorCorrect::get_color(Context context, const Point &pos)const { return correct_color(context.get_color(pos)); } - + bool Layer_ColorCorrect::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const {