Skip to content

Commit

Permalink
Fix color widget
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwarthog committed Dec 20, 2014
1 parent 6c99879 commit fa4af82
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
23 changes: 12 additions & 11 deletions synfig-studio/src/gui/widgets/widget_color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,14 @@ using namespace studio;

/* === P R O C E D U R E S ================================================= */

Gdk::Color
studio::colorconv_synfig2gdk(const synfig::Color &c_)
synfig::Color
studio::colorconv_apply_gamma(const synfig::Color &c_)
{
const synfig::Color c(c_.clamped());
Gdk::Color ret;
ret.set_rgb(
256*App::gamma.r_F32_to_U8(c.get_r()),
256*App::gamma.g_F32_to_U8(c.get_g()),
256*App::gamma.b_F32_to_U8(c.get_b())
);
return ret;
return synfig::Color(
App::gamma.r_F32_to_U8(c.get_r()),
App::gamma.g_F32_to_U8(c.get_g()),
App::gamma.b_F32_to_U8(c.get_b()) );
}

void
Expand All @@ -76,8 +73,12 @@ studio::render_color_to_window(const Cairo::RefPtr<Cairo::Context> &cr, const Gd
{
// In this case we need to render the alpha squares

const Color bg1(Color::blend(color,Color(0.75, 0.75, 0.75),1.0).clamped());
const Color bg2(Color::blend(color,Color(0.5, 0.5, 0.5),1.0).clamped());
const Color bg1(
colorconv_apply_gamma(
Color::blend(color,Color(0.75, 0.75, 0.75),1.0) ));
const Color bg2(
colorconv_apply_gamma(
Color::blend(color,Color(0.5, 0.5, 0.5),1.0) ));

bool toggle(false);
for(int i=0;i<width;i+=square_size)
Expand Down
2 changes: 1 addition & 1 deletion synfig-studio/src/gui/widgets/widget_color.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
namespace studio {


Gdk::Color colorconv_synfig2gdk(const synfig::Color &c);
synfig::Color colorconv_apply_gamma(const synfig::Color &c);

void render_color_to_window(const Cairo::RefPtr<Cairo::Context> &cr, const Gdk::Rectangle &ca, const synfig::Color &color);

Expand Down
7 changes: 2 additions & 5 deletions synfig-studio/src/gui/workarearenderer/renderer_ducks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,8 @@ Renderer_Ducks::render_vfunc(
((*iter2)[1]-window_start[1])/ph );

cr->set_line_width(1.0);
cr->set_source_rgb(
colorconv_synfig2gdk((*iter)->color).get_red_p(),
colorconv_synfig2gdk((*iter)->color).get_green_p(),
colorconv_synfig2gdk((*iter)->color).get_blue_p()
);
synfig::Color c = colorconv_apply_gamma((*iter)->color);
cr->set_source_rgb(c.get_r(), c.get_g(), c.get_b());
cr->stroke();

cr->restore();
Expand Down

0 comments on commit fa4af82

Please sign in to comment.