Work in HSL so luma can be preserved

Signed-off-by: artemp <artem@mapnik.org>
This commit is contained in:
Seth Fitzsimmons 2014-07-21 18:08:43 -07:00 committed by artemp
parent bfc6c61d62
commit 8476efbbba

View file

@ -1,6 +1,7 @@
#include "agg_pixfmt_rgba.h" #include "agg_pixfmt_rgba.h"
#include <boost/gil/gil_all.hpp> #include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/toolbox/hsv.hpp> #include <boost/gil/extension/toolbox/hsv.hpp>
#include <boost/gil/extension/toolbox/hsl.hpp>
//#include <iostream> //#include <iostream>
namespace agg namespace agg
@ -88,15 +89,16 @@ void comp_op_rgba_color<ColorT,Order>::blend_pix(value_type* p,
{ {
using namespace boost; using namespace boost;
using namespace gil; using namespace gil;
using namespace hsv_color_space; using namespace hsl_color_space;
rgb8_pixel_t rgb_src(sr,sg,sb); rgb8_pixel_t rgb_src(sr,sg,sb);
rgb8_pixel_t rgb_dst(p[Order::R],p[Order::G],p[Order::B]); rgb8_pixel_t rgb_dst(p[Order::R],p[Order::G],p[Order::B]);
hsv32f_pixel_t hsv_src,hsv_dst; hsl32f_pixel_t hsl_src,hsl_dst;
color_convert( rgb_src, hsv_src); color_convert( rgb_src, hsl_src);
color_convert( rgb_dst, hsv_dst); color_convert( rgb_dst, hsl_dst);
get_color(hsv_dst,hue_t()) = get_color(hsv_src,hue_t()); get_color(hsl_dst,hue_t()) = get_color(hsl_src,hue_t());
get_color(hsv_dst,saturation_t()) = get_color(hsv_src,saturation_t()); get_color(hsl_dst,saturation_t()) = get_color(hsl_src,saturation_t());
color_convert(hsv_dst, rgb_dst); get_color(hsl_dst,lightness_t()) = get_color(hsl_dst,lightness_t());
color_convert(hsl_dst, rgb_dst);
p[Order::R] = get_color(rgb_dst,red_t()); p[Order::R] = get_color(rgb_dst,red_t());
p[Order::G] = get_color(rgb_dst,green_t()); p[Order::G] = get_color(rgb_dst,green_t());
p[Order::B] = get_color(rgb_dst,blue_t()); p[Order::B] = get_color(rgb_dst,blue_t());