#1023 making gamma power default, making gamma-method awailable for polygon pattern symolizer and stroke

This commit is contained in:
Cezary Tarnowski 2012-01-13 18:20:03 +01:00
parent e7a751987d
commit 93ff232ca2
17 changed files with 225 additions and 73 deletions

View file

@ -62,17 +62,17 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
static boost::python::tuple static boost::python::tuple
getstate(const polygon_pattern_symbolizer& p) 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 static void
setstate (polygon_pattern_symbolizer& p, boost::python::tuple state) setstate (polygon_pattern_symbolizer& p, boost::python::tuple state)
{ {
using namespace boost::python; using namespace boost::python;
if (len(state) != 2) if (len(state) != 3)
{ {
PyErr_SetObject(PyExc_ValueError, 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() % state).ptr()
); );
throw_error_already_set(); throw_error_already_set();
@ -80,6 +80,7 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
p.set_alignment(extract<pattern_alignment_e>(state[0])); p.set_alignment(extract<pattern_alignment_e>(state[0]));
p.set_gamma(extract<float>(state[1])); p.set_gamma(extract<float>(state[1]));
p.set_gamma_method(extract<polygon_pattern_gamma_method_e>(state[2]));
} }
}; };
@ -92,6 +93,13 @@ void export_polygon_pattern_symbolizer()
.value("LOCAL",LOCAL_ALIGNMENT) .value("LOCAL",LOCAL_ALIGNMENT)
.value("GLOBAL",GLOBAL_ALIGNMENT) .value("GLOBAL",GLOBAL_ALIGNMENT)
; ;
enumeration_<polygon_pattern_gamma_method_e>("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_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer", class_<polygon_pattern_symbolizer>("PolygonPatternSymbolizer",
init<path_expression_ptr>("<path_expression_ptr>")) init<path_expression_ptr>("<path_expression_ptr>"))
@ -109,5 +117,9 @@ void export_polygon_pattern_symbolizer()
.add_property("gamma", .add_property("gamma",
&polygon_pattern_symbolizer::get_gamma, &polygon_pattern_symbolizer::get_gamma,
&polygon_pattern_symbolizer::set_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")
; ;
} }

View file

@ -58,7 +58,7 @@ struct polygon_symbolizer_pickle_suite : boost::python::pickle_suite
p.set_opacity(extract<float>(state[0])); p.set_opacity(extract<float>(state[0]));
p.set_gamma(extract<float>(state[1])); p.set_gamma(extract<float>(state[1]));
p.set_gamma_method(extract<gamma_method_e>(state[2])); p.set_gamma_method(extract<polygon_gamma_method_e>(state[2]));
} }
}; };
@ -67,12 +67,12 @@ void export_polygon_symbolizer()
{ {
using namespace boost::python; using namespace boost::python;
enumeration_<gamma_method_e>("gamma_method") enumeration_<polygon_gamma_method_e>("gamma_method")
.value("POWER", GAMMA_POWER) .value("POWER", POLYGON_GAMMA_POWER)
.value("LINEAR", GAMMA_LINEAR) .value("LINEAR", POLYGON_GAMMA_LINEAR)
.value("NONE", GAMMA_NONE) .value("NONE", POLYGON_GAMMA_NONE)
.value("THRESHOLD", GAMMA_THRESHOLD) .value("THRESHOLD", POLYGON_GAMMA_THRESHOLD)
.value("MULTIPLY", GAMMA_MULTIPLY) .value("MULTIPLY", POLYGON_GAMMA_MULTIPLY)
; ;
class_<polygon_symbolizer>("PolygonSymbolizer", class_<polygon_symbolizer>("PolygonSymbolizer",

View file

@ -68,17 +68,18 @@ struct stroke_pickle_suite : boost::python::pickle_suite
dashes, dashes,
s.get_line_cap(), s.get_line_cap(),
s.get_line_join(), s.get_line_join(),
s.get_gamma()); s.get_gamma(),
s.get_gamma_method());
} }
static void static void
setstate (stroke& s, boost::python::tuple state) setstate (stroke& s, boost::python::tuple state)
{ {
using namespace boost::python; using namespace boost::python;
if (len(state) != 5) if (len(state) != 6)
{ {
PyErr_SetObject(PyExc_ValueError, 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() % state).ptr()
); );
throw_error_already_set(); throw_error_already_set();
@ -99,6 +100,7 @@ struct stroke_pickle_suite : boost::python::pickle_suite
s.set_line_cap(extract<line_cap_e>(state[2])); s.set_line_cap(extract<line_cap_e>(state[2]));
s.set_line_join(extract<line_join_e>(state[3])); s.set_line_join(extract<line_join_e>(state[3]));
s.set_gamma(extract<double>(state[4])); s.set_gamma(extract<double>(state[4]));
s.set_gamma_method(extract<gamma_method_e>(state[5]));
} }
@ -124,6 +126,13 @@ void export_stroke ()
.value("ROUND_JOIN",ROUND_JOIN) .value("ROUND_JOIN",ROUND_JOIN)
.value("BEVEL_JOIN",BEVEL_JOIN) .value("BEVEL_JOIN",BEVEL_JOIN)
; ;
enumeration_<gamma_method_e>("gamma_method")
.value("POWER", GAMMA_POWER)
.value("LINEAR", GAMMA_LINEAR)
.value("NONE", GAMMA_NONE)
.value("THRESHOLD", GAMMA_THRESHOLD)
.value("MULTIPLY", GAMMA_MULTIPLY)
;
class_<stroke>("Stroke",init<>( class_<stroke>("Stroke",init<>(
"Creates a new default black stroke with the width of 1.\n")) "Creates a new default black stroke with the width of 1.\n"))
@ -151,6 +160,10 @@ void export_stroke ()
&stroke::set_gamma, &stroke::set_gamma,
"Gets or sets the gamma of this stroke.\n" "Gets or sets the gamma of this stroke.\n"
"The value is a float between 0 and 1.\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", .add_property("line_cap",
&stroke::get_line_cap, &stroke::get_line_cap,
&stroke::set_line_cap, &stroke::set_line_cap,

View file

@ -38,21 +38,33 @@ enum pattern_alignment_enum {
DEFINE_ENUM( pattern_alignment_e, 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 : struct MAPNIK_DECL polygon_pattern_symbolizer :
public symbolizer_with_image, public symbolizer_base public symbolizer_with_image, public symbolizer_base
{ {
polygon_pattern_symbolizer(path_expression_ptr file); polygon_pattern_symbolizer(path_expression_ptr file);
polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs); polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs);
pattern_alignment_e get_alignment() const; pattern_alignment_e get_alignment() const;
void set_alignment(pattern_alignment_e align); void set_alignment(pattern_alignment_e align);
void set_gamma(double gamma); void set_gamma(double gamma);
double get_gamma() const; 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: private:
pattern_alignment_e alignment_; pattern_alignment_e alignment_;
double gamma_; double gamma_;
polygon_pattern_gamma_method_e gamma_method_;
}; };
} }

View file

@ -35,16 +35,16 @@
namespace mapnik namespace mapnik
{ {
enum gamma_method_enum { enum polygon_gamma_method_enum {
GAMMA_POWER, //agg::gamma_power POLYGON_GAMMA_POWER, //agg::gamma_power
GAMMA_LINEAR, //agg::gamma_linear POLYGON_GAMMA_LINEAR, //agg::gamma_linear
GAMMA_NONE, //agg::gamma_none POLYGON_GAMMA_NONE, //agg::gamma_none
GAMMA_THRESHOLD, //agg::gamma_threshold POLYGON_GAMMA_THRESHOLD, //agg::gamma_threshold
GAMMA_MULTIPLY, //agg::gamma_multiply POLYGON_GAMMA_MULTIPLY, //agg::gamma_multiply
gamma_method_enum_MAX polygon_gamma_method_enum_MAX
}; };
DEFINE_ENUM( gamma_method_e, gamma_method_enum ); DEFINE_ENUM( polygon_gamma_method_e, polygon_gamma_method_enum );
struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
{ {
@ -53,14 +53,14 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
fill_(color(128,128,128)), fill_(color(128,128,128)),
opacity_(1.0), opacity_(1.0),
gamma_(1.0), gamma_(1.0),
gamma_method_(GAMMA_POWER) {} gamma_method_(POLYGON_GAMMA_POWER) {}
polygon_symbolizer(color const& fill) polygon_symbolizer(color const& fill)
: symbolizer_base(), : symbolizer_base(),
fill_(fill), fill_(fill),
opacity_(1.0), opacity_(1.0),
gamma_(1.0), gamma_(1.0),
gamma_method_(GAMMA_POWER) {} gamma_method_(POLYGON_GAMMA_POWER) {}
color const& get_fill() const color const& get_fill() const
{ {
@ -86,11 +86,11 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
{ {
return gamma_; return gamma_;
} }
void set_gamma_method(gamma_method_e gamma_method) void set_gamma_method(polygon_gamma_method_e gamma_method)
{ {
gamma_method_ = gamma_method; gamma_method_ = gamma_method;
} }
gamma_method_e get_gamma_method() const polygon_gamma_method_e get_gamma_method() const
{ {
return gamma_method_; return gamma_method_;
} }
@ -99,7 +99,7 @@ private:
color fill_; color fill_;
double opacity_; double opacity_;
double gamma_; double gamma_;
gamma_method_e gamma_method_; polygon_gamma_method_e gamma_method_;
}; };
struct MAPNIK_DECL building_symbolizer : public symbolizer_base struct MAPNIK_DECL building_symbolizer : public symbolizer_base

View file

@ -60,15 +60,27 @@ enum line_join_enum
}; };
DEFINE_ENUM( line_join_e, 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 class MAPNIK_DECL stroke
{ {
color c_; color c_;
double width_; double width_;
double opacity_; // 0.0 - 1.0 double opacity_; // 0.0 - 1.0
line_cap_e line_cap_; line_cap_e line_cap_;
line_join_e line_join_; line_join_e line_join_;
double gamma_; double gamma_;
gamma_method_e gamma_method_;
dash_array dash_; dash_array dash_;
double dash_offset_; double dash_offset_;
public: public:
@ -94,15 +106,18 @@ public:
void set_gamma(double gamma); void set_gamma(double gamma);
double get_gamma() const; 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); void add_dash(double dash,double gap);
bool has_dash() const; bool has_dash() const;
void set_dash_offset(double offset); void set_dash_offset(double offset);
double dash_offset() const; double dash_offset() const;
dash_array const& get_dash_array() const; dash_array const& get_dash_array() const;
private: private:
void swap(const stroke& other) throw(); void swap(const stroke& other) throw();
}; };

View file

@ -234,7 +234,7 @@ void agg_renderer<T>::render_marker(const int x, const int y, marker &marker, co
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
ras_ptr->reset(); ras_ptr->reset();
ras_ptr->gamma(agg::gamma_linear()); ras_ptr->gamma(agg::gamma_power());
agg::scanline_u8 sl; agg::scanline_u8 sl;
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);
pixfmt pixf(buf); pixfmt pixf(buf);

View file

@ -65,7 +65,7 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
agg::scanline_u8 sl; agg::scanline_u8 sl;
ras_ptr->reset(); ras_ptr->reset();
ras_ptr->gamma(agg::gamma_linear()); ras_ptr->gamma(agg::gamma_power());
double height = 0.0; double height = 0.0;
expression_ptr height_expr = sym.height(); expression_ptr height_expr = sym.height();

View file

@ -97,7 +97,26 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
ren_base renb(pixf); ren_base renb(pixf);
renderer ren(renb); renderer ren(renb);
ras_ptr->reset(); 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(); metawriter_with_properties writer = sym.get_metawriter();
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)

View file

@ -55,7 +55,7 @@ void agg_renderer<T>::process(markers_symbolizer const& sym,
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid;
ras_ptr->reset(); ras_ptr->reset();
ras_ptr->gamma(agg::gamma_linear()); ras_ptr->gamma(agg::gamma_power());
agg::scanline_u8 sl; agg::scanline_u8 sl;
agg::scanline_p8 sl_line; agg::scanline_p8 sl_line;
agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4); agg::rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_ * 4);

View file

@ -71,7 +71,26 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
agg::scanline_u8 sl; agg::scanline_u8 sl;
ras_ptr->reset(); 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); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
boost::optional<mapnik::marker_ptr> marker; boost::optional<mapnik::marker_ptr> marker;

View file

@ -62,24 +62,25 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
renderer ren(renb); renderer ren(renb);
ras_ptr->reset(); ras_ptr->reset();
switch (sym.get_gamma_method()) { switch (sym.get_gamma_method())
case GAMMA_POWER: {
ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); case GAMMA_POWER:
break; ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
case GAMMA_LINEAR: break;
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); case GAMMA_LINEAR:
break; ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
case GAMMA_NONE: break;
ras_ptr->gamma(agg::gamma_none()); case GAMMA_NONE:
break; ras_ptr->gamma(agg::gamma_none());
case GAMMA_THRESHOLD: break;
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma())); case GAMMA_THRESHOLD:
break; ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
case GAMMA_MULTIPLY: break;
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma())); case GAMMA_MULTIPLY:
break; ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
default: break;
ras_ptr->gamma(agg::gamma_power(sym.get_gamma())); default:
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
} }
metawriter_with_properties writer = sym.get_metawriter(); metawriter_with_properties writer = sym.get_metawriter();

View file

@ -1216,6 +1216,10 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
optional<double> gamma = get_opt_attr<double>(sym, "gamma"); optional<double> gamma = get_opt_attr<double>(sym, "gamma");
if (gamma) symbol.set_gamma(*gamma); if (gamma) symbol.set_gamma(*gamma);
// gamma method
optional<polygon_pattern_gamma_method_e> gamma_method = get_opt_attr<polygon_pattern_gamma_method_e>(sym, "gamma-method");
if (gamma_method) symbol.set_gamma_method(*gamma_method);
parse_metawriter_in_symbolizer(symbol, sym); parse_metawriter_in_symbolizer(symbol, sym);
rule.append(symbol); rule.append(symbol);
} }
@ -1794,6 +1798,10 @@ void map_parser::parse_stroke(stroke & strk, ptree const & sym)
optional<double> gamma = get_opt_attr<double>(sym, "stroke-gamma"); optional<double> gamma = get_opt_attr<double>(sym, "stroke-gamma");
if (gamma) strk.set_gamma(*gamma); if (gamma) strk.set_gamma(*gamma);
// stroke-gamma-method
optional<gamma_method_e> gamma_method = get_opt_attr<gamma_method_e>(sym, "stroke-gamma-method");
if (gamma_method) strk.set_gamma_method(*gamma_method);
// stroke-dashoffset // stroke-dashoffset
optional<double> dash_offset = get_opt_attr<double>(sym, "stroke-dashoffset"); optional<double> dash_offset = get_opt_attr<double>(sym, "stroke-dashoffset");
if (dash_offset) strk.set_dash_offset(*dash_offset); if (dash_offset) strk.set_dash_offset(*dash_offset);
@ -1886,8 +1894,8 @@ void map_parser::parse_polygon_symbolizer( rule & rule, ptree const & sym )
optional<double> gamma = get_opt_attr<double>(sym, "gamma"); optional<double> gamma = get_opt_attr<double>(sym, "gamma");
if (gamma) poly_sym.set_gamma(*gamma); if (gamma) poly_sym.set_gamma(*gamma);
// gamma method // gamma method
gamma_method_e gamma_method = get_attr<gamma_method_e>(sym, "gamma-method", GAMMA_POWER); optional<polygon_gamma_method_e> gamma_method = get_opt_attr<polygon_gamma_method_e>(sym, "gamma-method");
poly_sym.set_gamma_method(gamma_method); if (gamma_method) poly_sym.set_gamma_method(*gamma_method);
parse_metawriter_in_symbolizer(poly_sym, sym); parse_metawriter_in_symbolizer(poly_sym, sym);
rule.append(poly_sym); rule.append(poly_sym);

View file

@ -34,16 +34,29 @@ static const char * pattern_alignment_strings[] = {
}; };
IMPLEMENT_ENUM( pattern_alignment_e, 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(), : symbolizer_with_image(file), symbolizer_base(),
alignment_(LOCAL_ALIGNMENT), 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) polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs)
: symbolizer_with_image(rhs), symbolizer_base(rhs), : symbolizer_with_image(rhs), symbolizer_base(rhs),
alignment_(rhs.alignment_), alignment_(rhs.alignment_),
gamma_(rhs.gamma_) {} gamma_(rhs.gamma_),
gamma_method_(rhs.gamma_method_) {}
pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const
{ {
@ -65,5 +78,15 @@ void polygon_pattern_symbolizer::set_gamma(double gamma)
gamma_ = 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_;
}
} }

View file

@ -23,12 +23,11 @@
//$Id$ //$Id$
// mapnik // mapnik
#include <mapnik/polygon_symbolizer.hpp> #include <mapnik/polygon_symbolizer.hpp>
#include <mapnik/enumeration.hpp>
namespace mapnik namespace mapnik
{ {
static const char * gamma_method_strings[] = { static const char * polygon_gamma_method_strings[] = {
"power", //agg::gamma_power "power", //agg::gamma_power
"linear", //agg::gamma_linear "linear", //agg::gamma_linear
"none", //agg::gamma_none "none", //agg::gamma_none
@ -38,7 +37,7 @@ static const char * gamma_method_strings[] = {
}; };
IMPLEMENT_ENUM( gamma_method_e, gamma_method_strings ) IMPLEMENT_ENUM( polygon_gamma_method_e, polygon_gamma_method_strings )
} }

View file

@ -136,12 +136,14 @@ public:
{ {
set_attr( sym_node, "alignment", sym.get_alignment() ); set_attr( sym_node, "alignment", sym.get_alignment() );
} }
if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ ) if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ )
{ {
set_attr( sym_node, "gamma", sym.get_gamma() ); 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_image_attributes( sym_node, sym );
add_metawriter_attributes(sym_node, sym); add_metawriter_attributes(sym_node, sym);
} }
@ -610,6 +612,10 @@ private:
{ {
set_attr( node, "stroke-gamma", strk.get_gamma()); 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_ ) if ( strk.dash_offset() != dfl.dash_offset() || explicit_defaults_ )
{ {
set_attr( node, "stroke-dash-offset", strk.dash_offset()); set_attr( node, "stroke-dash-offset", strk.dash_offset());

View file

@ -46,6 +46,17 @@ static const char * line_join_strings[] = {
IMPLEMENT_ENUM( line_join_e, 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() stroke::stroke()
: c_(0,0,0), : c_(0,0,0),
@ -54,6 +65,7 @@ stroke::stroke()
line_cap_(BUTT_CAP), line_cap_(BUTT_CAP),
line_join_(MITER_JOIN), line_join_(MITER_JOIN),
gamma_(1.0), gamma_(1.0),
gamma_method_(GAMMA_POWER),
dash_(), dash_(),
dash_offset_(0) {} dash_offset_(0) {}
@ -64,6 +76,7 @@ stroke::stroke(color const& c, double width)
line_cap_(BUTT_CAP), line_cap_(BUTT_CAP),
line_join_(MITER_JOIN), line_join_(MITER_JOIN),
gamma_(1.0), gamma_(1.0),
gamma_method_(GAMMA_POWER),
dash_(), dash_(),
dash_offset_(0.0) {} dash_offset_(0.0) {}
@ -74,6 +87,7 @@ stroke::stroke(stroke const& other)
line_cap_(other.line_cap_), line_cap_(other.line_cap_),
line_join_(other.line_join_), line_join_(other.line_join_),
gamma_(other.gamma_), gamma_(other.gamma_),
gamma_method_(other.gamma_method_),
dash_(other.dash_), dash_(other.dash_),
dash_offset_(other.dash_offset_) {} dash_offset_(other.dash_offset_) {}
@ -145,6 +159,16 @@ double stroke::get_gamma() const
return gamma_; 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) void stroke::add_dash(double dash, double gap)
{ {
dash_.push_back(std::make_pair(dash,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() void stroke::swap(const stroke& other) throw()
{ {
c_=other.c_; c_ = other.c_;
width_=other.width_; width_ = other.width_;
opacity_=other.opacity_; opacity_ = other.opacity_;
line_cap_=other.line_cap_; line_cap_ = other.line_cap_;
line_join_=other.line_join_; line_join_ = other.line_join_;
gamma_=other.gamma_; gamma_ = other.gamma_;
gamma_method_ = other.gamma_method_;
dash_ = other.dash_; dash_ = other.dash_;
dash_offset_ = other.dash_offset_; dash_offset_ = other.dash_offset_;
} }