Utilise color alpha information when rendering. Multiplies the color alpha with the rendering opacity. Fixes 221.

This commit is contained in:
Jon Burgess 2009-02-07 14:09:23 +00:00
parent 5a3ce5a7ca
commit d11654895b
2 changed files with 12 additions and 8 deletions

View file

@ -184,6 +184,7 @@ namespace mapnik
unsigned r=fill_.red(); unsigned r=fill_.red();
unsigned g=fill_.green(); unsigned g=fill_.green();
unsigned b=fill_.blue(); unsigned b=fill_.blue();
unsigned a=fill_.alpha();
renderer ren(renb); renderer ren(renb);
ras_ptr->reset(); ras_ptr->reset();
@ -197,7 +198,7 @@ namespace mapnik
ras_ptr->add_path(path); ras_ptr->add_path(path);
} }
} }
ren.color(agg::rgba8(r, g, b, int(255 * sym.get_opacity()))); ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
} }
@ -227,6 +228,7 @@ namespace mapnik
unsigned r=fill_.red(); unsigned r=fill_.red();
unsigned g=fill_.green(); unsigned g=fill_.green();
unsigned b=fill_.blue(); unsigned b=fill_.blue();
unsigned a=fill_.alpha();
renderer ren(renb); renderer ren(renb);
agg::scanline_u8 sl; agg::scanline_u8 sl;
@ -275,7 +277,7 @@ namespace mapnik
path_type faces_path (t_,*faces,prj_trans); path_type faces_path (t_,*faces,prj_trans);
ras_ptr->add_path(faces_path); ras_ptr->add_path(faces_path);
ren.color(agg::rgba8(int(r*0.8), int(g*0.8), int(b*0.8), int(255 * sym.get_opacity()))); ren.color(agg::rgba8(int(r*0.8), int(g*0.8), int(b*0.8), int(a * sym.get_opacity())));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
ras_ptr->reset(); ras_ptr->reset();
@ -308,7 +310,7 @@ namespace mapnik
path_type roof_path (t_,*roof,prj_trans); path_type roof_path (t_,*roof,prj_trans);
ras_ptr->add_path(roof_path); ras_ptr->add_path(roof_path);
ren.color(agg::rgba8(r, g, b, int(255 * sym.get_opacity()))); ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
} }
} }
@ -334,6 +336,7 @@ namespace mapnik
unsigned r=col.red(); unsigned r=col.red();
unsigned g=col.green(); unsigned g=col.green();
unsigned b=col.blue(); unsigned b=col.blue();
unsigned a=col.alpha();
renderer ren(renb); renderer ren(renb);
ras_ptr->reset(); ras_ptr->reset();
agg::scanline_p8 sl; agg::scanline_p8 sl;
@ -409,7 +412,7 @@ namespace mapnik
} }
} }
} }
ren.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity()))); ren.color(agg::rgba8(r, g, b, int(a*stroke_.get_opacity())));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
} }
@ -693,6 +696,7 @@ namespace mapnik
unsigned r = 0;// fill_.red(); unsigned r = 0;// fill_.red();
unsigned g = 0; //fill_.green(); unsigned g = 0; //fill_.green();
unsigned b = 255; //fill_.blue(); unsigned b = 255; //fill_.blue();
unsigned a = 255; //fill_.alpha();
renderer ren(renb); renderer ren(renb);
for (unsigned i=0;i<feature.num_geometries();++i) for (unsigned i=0;i<feature.num_geometries();++i)
{ {
@ -710,7 +714,7 @@ namespace mapnik
ras_ptr->add_path(marker); ras_ptr->add_path(marker);
} }
} }
ren.color(agg::rgba8(r, g, b, 255)); ren.color(agg::rgba8(r, g, b, a));
agg::render_scanlines(*ras_ptr, sl, ren); agg::render_scanlines(*ras_ptr, sl, ren);
} }

View file

@ -206,7 +206,7 @@ namespace mapnik
void set_color(color const &color, double opacity = 1.0) void set_color(color const &color, double opacity = 1.0)
{ {
set_color(color.red(), color.green(), color.blue(), opacity); set_color(color.red(), color.green(), color.blue(), color.alpha() * opacity / 255.0);
} }
void set_color(int r, int g, int b, double opacity = 1.0) void set_color(int r, int g, int b, double opacity = 1.0)
@ -512,7 +512,7 @@ namespace mapnik
if (bg) if (bg)
{ {
cairo_context context(context_); cairo_context context(context_);
context.set_color(*bg, bg->alpha()/255.0); context.set_color(*bg);
context.paint(); context.paint();
} }
} }
@ -647,7 +647,7 @@ namespace mapnik
path_type faces_path(t_, *faces, prj_trans); path_type faces_path(t_, *faces, prj_trans);
context.set_color(int(fill.red() * 0.8), int(fill.green() * 0.8), context.set_color(int(fill.red() * 0.8), int(fill.green() * 0.8),
int(fill.blue() * 0.8), sym.get_opacity()); int(fill.blue() * 0.8), fill.alpha() * sym.get_opacity() / 255.0);
context.add_path(faces_path); context.add_path(faces_path);
context.fill(); context.fill();