diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index ae972556a..3ae556c55 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -62,17 +62,17 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite static boost::python::tuple getstate(const polygon_pattern_symbolizer& p) { - return boost::python::make_tuple(p.get_alignment(),p.get_gamma()); + return boost::python::make_tuple(p.get_alignment(),p.get_gamma(),p.get_gamma_method()); } static void setstate (polygon_pattern_symbolizer& p, boost::python::tuple state) { using namespace boost::python; - if (len(state) != 2) + if (len(state) != 3) { PyErr_SetObject(PyExc_ValueError, - ("expected 2-item tuple in call to __setstate__; got %s" + ("expected 3-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); @@ -80,6 +80,7 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite p.set_alignment(extract(state[0])); p.set_gamma(extract(state[1])); + p.set_gamma_method(extract(state[2])); } }; @@ -92,6 +93,13 @@ void export_polygon_pattern_symbolizer() .value("LOCAL",LOCAL_ALIGNMENT) .value("GLOBAL",GLOBAL_ALIGNMENT) ; + enumeration_("gamma_method") + .value("POWER", POLYGON_PATTERN_GAMMA_POWER) + .value("LINEAR", POLYGON_PATTERN_GAMMA_LINEAR) + .value("NONE", POLYGON_PATTERN_GAMMA_NONE) + .value("THRESHOLD", POLYGON_PATTERN_GAMMA_THRESHOLD) + .value("MULTIPLY", POLYGON_PATTERN_GAMMA_MULTIPLY) + ; class_("PolygonPatternSymbolizer", init("")) @@ -109,5 +117,9 @@ void export_polygon_pattern_symbolizer() .add_property("gamma", &polygon_pattern_symbolizer::get_gamma, &polygon_pattern_symbolizer::set_gamma) + .add_property("gamma_method", + &polygon_pattern_symbolizer::get_gamma_method, + &polygon_pattern_symbolizer::set_gamma_method, + "Set/get the gamma correction method of the polygon") ; } diff --git a/bindings/python/mapnik_polygon_symbolizer.cpp b/bindings/python/mapnik_polygon_symbolizer.cpp index 9caa4b4c5..09c7591dc 100644 --- a/bindings/python/mapnik_polygon_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_symbolizer.cpp @@ -22,8 +22,10 @@ //$Id$ #include +#include "mapnik_enumeration.hpp" #include +using namespace mapnik; using mapnik::polygon_symbolizer; using mapnik::color; @@ -38,17 +40,17 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite static boost::python::tuple getstate(const polygon_symbolizer& p) { - return boost::python::make_tuple(p.get_opacity(),p.get_gamma()); + return boost::python::make_tuple(p.get_opacity(),p.get_gamma(),p.get_gamma_method()); } static void setstate (polygon_symbolizer& p, boost::python::tuple state) { using namespace boost::python; - if (len(state) != 2) + if (len(state) != 3) { PyErr_SetObject(PyExc_ValueError, - ("expected 2-item tuple in call to __setstate__; got %s" + ("expected 3-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); @@ -56,6 +58,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite p.set_opacity(extract(state[0])); p.set_gamma(extract(state[1])); + p.set_gamma_method(extract(state[2])); } }; @@ -64,6 +67,14 @@ void export_polygon_symbolizer() { using namespace boost::python; + enumeration_("gamma_method") + .value("POWER", POLYGON_GAMMA_POWER) + .value("LINEAR", POLYGON_GAMMA_LINEAR) + .value("NONE", POLYGON_GAMMA_NONE) + .value("THRESHOLD", POLYGON_GAMMA_THRESHOLD) + .value("MULTIPLY", POLYGON_GAMMA_MULTIPLY) + ; + class_("PolygonSymbolizer", init<>("Default PolygonSymbolizer - solid fill grey")) .def(init("TODO")) @@ -78,6 +89,10 @@ void export_polygon_symbolizer() .add_property("gamma", &polygon_symbolizer::get_gamma, &polygon_symbolizer::set_gamma) + .add_property("gamma_method", + &polygon_symbolizer::get_gamma_method, + &polygon_symbolizer::set_gamma_method, + "Set/get the gamma correction method of the polygon") ; } diff --git a/bindings/python/mapnik_stroke.cpp b/bindings/python/mapnik_stroke.cpp index 9835c1437..09f2a7027 100644 --- a/bindings/python/mapnik_stroke.cpp +++ b/bindings/python/mapnik_stroke.cpp @@ -68,17 +68,18 @@ struct stroke_pickle_suite : boost::python::pickle_suite dashes, s.get_line_cap(), s.get_line_join(), - s.get_gamma()); + s.get_gamma(), + s.get_gamma_method()); } static void setstate (stroke& s, boost::python::tuple state) { using namespace boost::python; - if (len(state) != 5) + if (len(state) != 6) { PyErr_SetObject(PyExc_ValueError, - ("expected 5-item tuple in call to __setstate__; got %s" + ("expected 6-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); @@ -99,6 +100,7 @@ struct stroke_pickle_suite : boost::python::pickle_suite s.set_line_cap(extract(state[2])); s.set_line_join(extract(state[3])); s.set_gamma(extract(state[4])); + s.set_gamma_method(extract(state[5])); } @@ -124,6 +126,13 @@ void export_stroke () .value("ROUND_JOIN",ROUND_JOIN) .value("BEVEL_JOIN",BEVEL_JOIN) ; + enumeration_("gamma_method") + .value("POWER", GAMMA_POWER) + .value("LINEAR", GAMMA_LINEAR) + .value("NONE", GAMMA_NONE) + .value("THRESHOLD", GAMMA_THRESHOLD) + .value("MULTIPLY", GAMMA_MULTIPLY) + ; class_("Stroke",init<>( "Creates a new default black stroke with the width of 1.\n")) @@ -151,6 +160,10 @@ void export_stroke () &stroke::set_gamma, "Gets or sets the gamma of this stroke.\n" "The value is a float between 0 and 1.\n") + .add_property("gamma_method", + &stroke::get_gamma_method, + &stroke::set_gamma_method, + "Set/get the gamma correction method of this stroke") .add_property("line_cap", &stroke::get_line_cap, &stroke::set_line_cap, diff --git a/include/mapnik/polygon_pattern_symbolizer.hpp b/include/mapnik/polygon_pattern_symbolizer.hpp index e1ffc39b9..cdc485596 100644 --- a/include/mapnik/polygon_pattern_symbolizer.hpp +++ b/include/mapnik/polygon_pattern_symbolizer.hpp @@ -38,21 +38,33 @@ enum pattern_alignment_enum { DEFINE_ENUM( pattern_alignment_e, pattern_alignment_enum ); +enum polygon_pattern_gamma_method_enum { + POLYGON_PATTERN_GAMMA_POWER, //agg::gamma_power + POLYGON_PATTERN_GAMMA_LINEAR, //agg::gamma_linear + POLYGON_PATTERN_GAMMA_NONE, //agg::gamma_none + POLYGON_PATTERN_GAMMA_THRESHOLD, //agg::gamma_threshold + POLYGON_PATTERN_GAMMA_MULTIPLY, //agg::gamma_multiply + polygon_pattern_gamma_method_enum_MAX +}; + +DEFINE_ENUM( polygon_pattern_gamma_method_e, polygon_pattern_gamma_method_enum ); + struct MAPNIK_DECL polygon_pattern_symbolizer : public symbolizer_with_image, public symbolizer_base { - polygon_pattern_symbolizer(path_expression_ptr file); polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs); pattern_alignment_e get_alignment() const; void set_alignment(pattern_alignment_e align); void set_gamma(double gamma); double get_gamma() const; + void set_gamma_method(polygon_pattern_gamma_method_e gamma_method); + polygon_pattern_gamma_method_e get_gamma_method() const; private: pattern_alignment_e alignment_; double gamma_; - + polygon_pattern_gamma_method_e gamma_method_; }; } diff --git a/include/mapnik/polygon_symbolizer.hpp b/include/mapnik/polygon_symbolizer.hpp index a4791eed3..7bee50d91 100644 --- a/include/mapnik/polygon_symbolizer.hpp +++ b/include/mapnik/polygon_symbolizer.hpp @@ -27,22 +27,40 @@ #include #include #include +#include + +// stl +#include namespace mapnik { + +enum polygon_gamma_method_enum { + POLYGON_GAMMA_POWER, //agg::gamma_power + POLYGON_GAMMA_LINEAR, //agg::gamma_linear + POLYGON_GAMMA_NONE, //agg::gamma_none + POLYGON_GAMMA_THRESHOLD, //agg::gamma_threshold + POLYGON_GAMMA_MULTIPLY, //agg::gamma_multiply + polygon_gamma_method_enum_MAX +}; + +DEFINE_ENUM( polygon_gamma_method_e, polygon_gamma_method_enum ); + struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base { explicit polygon_symbolizer() : symbolizer_base(), fill_(color(128,128,128)), opacity_(1.0), - gamma_(1.0) {} + gamma_(1.0), + gamma_method_(POLYGON_GAMMA_POWER) {} polygon_symbolizer(color const& fill) : symbolizer_base(), fill_(fill), opacity_(1.0), - gamma_(1.0) {} + gamma_(1.0), + gamma_method_(POLYGON_GAMMA_POWER) {} color const& get_fill() const { @@ -68,11 +86,20 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base { return gamma_; } + void set_gamma_method(polygon_gamma_method_e gamma_method) + { + gamma_method_ = gamma_method; + } + polygon_gamma_method_e get_gamma_method() const + { + return gamma_method_; + } private: color fill_; double opacity_; double gamma_; + polygon_gamma_method_e gamma_method_; }; struct MAPNIK_DECL building_symbolizer : public symbolizer_base diff --git a/include/mapnik/stroke.hpp b/include/mapnik/stroke.hpp index 36b6a882c..653fc4516 100644 --- a/include/mapnik/stroke.hpp +++ b/include/mapnik/stroke.hpp @@ -60,15 +60,27 @@ enum line_join_enum }; DEFINE_ENUM( line_join_e, line_join_enum ); - + +enum gamma_method_enum { + GAMMA_POWER, //agg::gamma_power + GAMMA_LINEAR, //agg::gamma_linear + GAMMA_NONE, //agg::gamma_none + GAMMA_THRESHOLD, //agg::gamma_threshold + GAMMA_MULTIPLY, //agg::gamma_multiply + gamma_method_enum_MAX +}; + +DEFINE_ENUM( gamma_method_e, gamma_method_enum ); + class MAPNIK_DECL stroke -{ +{ color c_; double width_; double opacity_; // 0.0 - 1.0 line_cap_e line_cap_; line_join_e line_join_; double gamma_; + gamma_method_e gamma_method_; dash_array dash_; double dash_offset_; public: @@ -94,15 +106,18 @@ public: void set_gamma(double gamma); double get_gamma() const; - + + void set_gamma_method(gamma_method_e gamma_method); + gamma_method_e get_gamma_method() const; + void add_dash(double dash,double gap); bool has_dash() const; void set_dash_offset(double offset); double dash_offset() const; - + dash_array const& get_dash_array() const; - + private: void swap(const stroke& other) throw(); }; diff --git a/src/agg/agg_renderer.cpp b/src/agg/agg_renderer.cpp index 9275c0d76..a2ef94c34 100644 --- a/src/agg/agg_renderer.cpp +++ b/src/agg/agg_renderer.cpp @@ -234,7 +234,7 @@ void agg_renderer::render_marker(const int x, const int y, marker &marker, co typedef agg::renderer_scanline_aa_solid renderer_solid; ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear()); + ras_ptr->gamma(agg::gamma_power()); agg::scanline_u8 sl; agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); pixfmt pixf(buf); diff --git a/src/agg/process_building_symbolizer.cpp b/src/agg/process_building_symbolizer.cpp index f28b17fdc..2f619b842 100644 --- a/src/agg/process_building_symbolizer.cpp +++ b/src/agg/process_building_symbolizer.cpp @@ -65,7 +65,7 @@ void agg_renderer::process(building_symbolizer const& sym, agg::scanline_u8 sl; ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear()); + ras_ptr->gamma(agg::gamma_power()); double height = 0.0; expression_ptr height_expr = sym.height(); diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index c44cb273c..eaef2e7e8 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -97,7 +97,26 @@ void agg_renderer::process(line_symbolizer const& sym, ren_base renb(pixf); renderer ren(renb); ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma())); + switch (stroke_.get_gamma_method()) + { + case GAMMA_POWER: + ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma())); + break; + case GAMMA_LINEAR: + ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma())); + break; + case GAMMA_NONE: + ras_ptr->gamma(agg::gamma_none()); + break; + case GAMMA_THRESHOLD: + ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma())); + break; + case GAMMA_MULTIPLY: + ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma())); + break; + default: + ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma())); + } metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;i::process(markers_symbolizer const& sym, typedef agg::renderer_scanline_aa_solid renderer_solid; ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear()); + ras_ptr->gamma(agg::gamma_power()); agg::scanline_u8 sl; agg::scanline_p8 sl_line; agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index a9a036ae5..042f3a3c6 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -71,7 +71,26 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::scanline_u8 sl; ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); + switch (sym.get_gamma_method()) + { + case GAMMA_POWER: + ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); + break; + case GAMMA_LINEAR: + ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); + break; + case GAMMA_NONE: + ras_ptr->gamma(agg::gamma_none()); + break; + case GAMMA_THRESHOLD: + ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma())); + break; + case GAMMA_MULTIPLY: + ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma())); + break; + default: + ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); + } std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); boost::optional marker; diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index a3c3f9d1d..2427cdc3f 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -62,7 +62,27 @@ void agg_renderer::process(polygon_symbolizer const& sym, renderer ren(renb); ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); + switch (sym.get_gamma_method()) + { + case GAMMA_POWER: + ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); + break; + case GAMMA_LINEAR: + ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); + break; + case GAMMA_NONE: + ras_ptr->gamma(agg::gamma_none()); + break; + case GAMMA_THRESHOLD: + ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma())); + break; + case GAMMA_MULTIPLY: + ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma())); + break; + default: + ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); + } + metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;i gamma = get_opt_attr(sym, "gamma"); if (gamma) symbol.set_gamma(*gamma); + // gamma method + optional gamma_method = get_opt_attr(sym, "gamma-method"); + if (gamma_method) symbol.set_gamma_method(*gamma_method); + parse_metawriter_in_symbolizer(symbol, sym); rule.append(symbol); } @@ -1794,6 +1798,10 @@ void map_parser::parse_stroke(stroke & strk, ptree const & sym) optional gamma = get_opt_attr(sym, "stroke-gamma"); if (gamma) strk.set_gamma(*gamma); + // stroke-gamma-method + optional gamma_method = get_opt_attr(sym, "stroke-gamma-method"); + if (gamma_method) strk.set_gamma_method(*gamma_method); + // stroke-dashoffset optional dash_offset = get_opt_attr(sym, "stroke-dashoffset"); if (dash_offset) strk.set_dash_offset(*dash_offset); @@ -1872,7 +1880,7 @@ void map_parser::parse_line_symbolizer( rule & rule, ptree const & sym ) void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym ) { - ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,gamma,meta-writer,meta-output"); + ensure_attrs(sym, "PolygonSymbolizer", "fill,fill-opacity,gamma,gamma-method,meta-writer,meta-output"); try { polygon_symbolizer poly_sym; @@ -1885,6 +1893,9 @@ void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym ) // gamma optional gamma = get_opt_attr(sym, "gamma"); if (gamma) poly_sym.set_gamma(*gamma); + // gamma method + optional gamma_method = get_opt_attr(sym, "gamma-method"); + if (gamma_method) poly_sym.set_gamma_method(*gamma_method); parse_metawriter_in_symbolizer(poly_sym, sym); rule.append(poly_sym); diff --git a/src/polygon_pattern_symbolizer.cpp b/src/polygon_pattern_symbolizer.cpp index 234fc000b..f3b279b9c 100644 --- a/src/polygon_pattern_symbolizer.cpp +++ b/src/polygon_pattern_symbolizer.cpp @@ -34,16 +34,29 @@ static const char * pattern_alignment_strings[] = { }; IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings ) - -polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file) + +static const char * polygon_pattern_gamma_method_strings[] = { + "power", //agg::gamma_power + "linear", //agg::gamma_linear + "none", //agg::gamma_none + "threshold", //agg::gamma_threshold + "multiply", //agg::gamma_multiply", + "" +}; + +IMPLEMENT_ENUM( polygon_pattern_gamma_method_e, polygon_pattern_gamma_method_strings ) + +polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file) : symbolizer_with_image(file), symbolizer_base(), alignment_(LOCAL_ALIGNMENT), - gamma_(1.0) {} + gamma_(1.0), + gamma_method_(POLYGON_PATTERN_GAMMA_POWER) {} polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs) : symbolizer_with_image(rhs), symbolizer_base(rhs), alignment_(rhs.alignment_), - gamma_(rhs.gamma_) {} + gamma_(rhs.gamma_), + gamma_method_(rhs.gamma_method_) {} pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const { @@ -65,5 +78,15 @@ void polygon_pattern_symbolizer::set_gamma(double gamma) gamma_ = gamma; } +void polygon_pattern_symbolizer::set_gamma_method(polygon_pattern_gamma_method_e gamma_method) +{ + gamma_method_ = gamma_method; +} + +polygon_pattern_gamma_method_e polygon_pattern_symbolizer::get_gamma_method() const +{ + return gamma_method_; +} + } diff --git a/src/polygon_symbolizer.cpp b/src/polygon_symbolizer.cpp new file mode 100644 index 000000000..d5e7fe572 --- /dev/null +++ b/src/polygon_symbolizer.cpp @@ -0,0 +1,43 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +//$Id$ +// mapnik +#include + +namespace mapnik +{ + +static const char * polygon_gamma_method_strings[] = { + "power", //agg::gamma_power + "linear", //agg::gamma_linear + "none", //agg::gamma_none + "threshold", //agg::gamma_threshold + "multiply", //agg::gamma_multiply", + "" +}; + + +IMPLEMENT_ENUM( polygon_gamma_method_e, polygon_gamma_method_strings ) + +} + diff --git a/src/save_map.cpp b/src/save_map.cpp index a26fd3d93..3cf56b014 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -118,6 +118,10 @@ public: { set_attr( sym_node, "gamma", sym.get_gamma() ); } + if ( sym.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ ) + { + set_attr( sym_node, "gamma-method", sym.get_gamma_method() ); + } add_metawriter_attributes(sym_node, sym); } @@ -132,12 +136,14 @@ public: { set_attr( sym_node, "alignment", sym.get_alignment() ); } - if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ ) { set_attr( sym_node, "gamma", sym.get_gamma() ); } - + if ( sym.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ ) + { + set_attr( sym_node, "gamma-method", sym.get_gamma_method() ); + } add_image_attributes( sym_node, sym ); add_metawriter_attributes(sym_node, sym); } @@ -606,6 +612,10 @@ private: { set_attr( node, "stroke-gamma", strk.get_gamma()); } + if ( strk.get_gamma_method() != dfl.get_gamma_method() || explicit_defaults_ ) + { + set_attr( node, "stroke-gamma-method", strk.get_gamma_method() ); + } if ( strk.dash_offset() != dfl.dash_offset() || explicit_defaults_ ) { set_attr( node, "stroke-dash-offset", strk.dash_offset()); diff --git a/src/stroke.cpp b/src/stroke.cpp index fbce4542d..7484b3e36 100644 --- a/src/stroke.cpp +++ b/src/stroke.cpp @@ -46,6 +46,17 @@ static const char * line_join_strings[] = { IMPLEMENT_ENUM( line_join_e, line_join_strings ) +static const char * gamma_method_strings[] = { + "power", //agg::gamma_power + "linear", //agg::gamma_linear + "none", //agg::gamma_none + "threshold", //agg::gamma_threshold + "multiply", //agg::gamma_multiply", + "" +}; + +IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) + stroke::stroke() : c_(0,0,0), @@ -54,6 +65,7 @@ stroke::stroke() line_cap_(BUTT_CAP), line_join_(MITER_JOIN), gamma_(1.0), + gamma_method_(GAMMA_POWER), dash_(), dash_offset_(0) {} @@ -64,6 +76,7 @@ stroke::stroke(color const& c, double width) line_cap_(BUTT_CAP), line_join_(MITER_JOIN), gamma_(1.0), + gamma_method_(GAMMA_POWER), dash_(), dash_offset_(0.0) {} @@ -74,6 +87,7 @@ stroke::stroke(stroke const& other) line_cap_(other.line_cap_), line_join_(other.line_join_), gamma_(other.gamma_), + gamma_method_(other.gamma_method_), dash_(other.dash_), dash_offset_(other.dash_offset_) {} @@ -145,6 +159,16 @@ double stroke::get_gamma() const return gamma_; } +void stroke::set_gamma_method(gamma_method_e gamma_method) +{ + gamma_method_ = gamma_method; +} + +gamma_method_e stroke::get_gamma_method() const +{ + return gamma_method_; +} + void stroke::add_dash(double dash, double gap) { dash_.push_back(std::make_pair(dash,gap)); @@ -172,12 +196,13 @@ dash_array const& stroke::get_dash_array() const void stroke::swap(const stroke& other) throw() { - c_=other.c_; - width_=other.width_; - opacity_=other.opacity_; - line_cap_=other.line_cap_; - line_join_=other.line_join_; - gamma_=other.gamma_; + c_ = other.c_; + width_ = other.width_; + opacity_ = other.opacity_; + line_cap_ = other.line_cap_; + line_join_ = other.line_join_; + gamma_ = other.gamma_; + gamma_method_ = other.gamma_method_; dash_ = other.dash_; dash_offset_ = other.dash_offset_; }