fix handling of svg opacity, which should be applied to fill/stroke opacity at render time - closes #1744
This commit is contained in:
parent
3b834b4e6f
commit
29ce3b1c75
4 changed files with 11 additions and 8 deletions
|
@ -264,6 +264,7 @@ public:
|
|||
{
|
||||
cur_attr().fill_opacity = op;
|
||||
}
|
||||
|
||||
void stroke_opacity(double op)
|
||||
{
|
||||
cur_attr().stroke_opacity = op;
|
||||
|
@ -271,8 +272,7 @@ public:
|
|||
|
||||
void opacity(double op)
|
||||
{
|
||||
cur_attr().stroke_opacity = op;
|
||||
cur_attr().fill_opacity = op;
|
||||
cur_attr().opacity = op;
|
||||
}
|
||||
|
||||
void line_join(agg::line_join_e join)
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace svg {
|
|||
struct path_attributes
|
||||
{
|
||||
unsigned index;
|
||||
double opacity;
|
||||
agg::rgba8 fill_color;
|
||||
double fill_opacity;
|
||||
agg::rgba8 stroke_color;
|
||||
|
@ -58,6 +59,7 @@ struct path_attributes
|
|||
// Empty constructor
|
||||
path_attributes() :
|
||||
index(0),
|
||||
opacity(1.0),
|
||||
fill_color(agg::rgba(0,0,0)),
|
||||
fill_opacity(1.0),
|
||||
stroke_color(agg::rgba(0,0,0)),
|
||||
|
@ -80,6 +82,7 @@ struct path_attributes
|
|||
// Copy constructor
|
||||
path_attributes(const path_attributes& attr)
|
||||
: index(attr.index),
|
||||
opacity(attr.opacity),
|
||||
fill_color(attr.fill_color),
|
||||
fill_opacity(attr.fill_opacity),
|
||||
stroke_color(attr.stroke_color),
|
||||
|
@ -101,6 +104,7 @@ struct path_attributes
|
|||
// Copy constructor with new index value
|
||||
path_attributes(path_attributes const& attr, unsigned idx)
|
||||
: index(idx),
|
||||
opacity(attr.opacity),
|
||||
fill_color(attr.fill_color),
|
||||
fill_opacity(attr.fill_opacity),
|
||||
stroke_color(attr.stroke_color),
|
||||
|
|
|
@ -290,13 +290,13 @@ public:
|
|||
|
||||
if(attr.fill_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * opacity, symbol_bbox, path_bbox);
|
||||
render_gradient(ras, sl, ren, attr.fill_gradient, transform, attr.fill_opacity * attr.opacity * opacity, symbol_bbox, path_bbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
ras.filling_rule(attr.even_odd_flag ? fill_even_odd : fill_non_zero);
|
||||
color = attr.fill_color;
|
||||
color.opacity(color.opacity() * attr.fill_opacity * opacity);
|
||||
color.opacity(color.opacity() * attr.fill_opacity * attr.opacity * opacity);
|
||||
ScanlineRenderer ren_s(ren);
|
||||
color.premultiply();
|
||||
ren_s.color(color);
|
||||
|
@ -326,13 +326,13 @@ public:
|
|||
|
||||
if(attr.stroke_gradient.get_gradient_type() != NO_GRADIENT)
|
||||
{
|
||||
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * opacity, symbol_bbox, path_bbox);
|
||||
render_gradient(ras, sl, ren, attr.stroke_gradient, transform, attr.stroke_opacity * attr.opacity * opacity, symbol_bbox, path_bbox);
|
||||
}
|
||||
else
|
||||
{
|
||||
ras.filling_rule(fill_non_zero);
|
||||
color = attr.stroke_color;
|
||||
color.opacity(color.opacity() * attr.stroke_opacity * opacity);
|
||||
color.opacity(color.opacity() * attr.stroke_opacity * attr.opacity * opacity);
|
||||
ScanlineRenderer ren_s(ren);
|
||||
color.premultiply();
|
||||
ren_s.color(color);
|
||||
|
|
|
@ -411,8 +411,7 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value )
|
|||
else if(xmlStrEqual(name, BAD_CAST "opacity"))
|
||||
{
|
||||
double opacity = parse_double((const char*)value);
|
||||
path_.stroke_opacity(opacity);
|
||||
path_.fill_opacity(opacity);
|
||||
path_.opacity(opacity);
|
||||
}
|
||||
else if (xmlStrEqual(name, BAD_CAST "visibility"))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue