Fix incorrect blending of rasters with alpha channel. Use pixfmt_rgba32_plain rather than pixfmt_rgba32, and undo old changes to blender_rgba<>::blender_pix which aren't needed anymore. Thanks @rfw, @cdestigter, @albertov [fixes #759]
This commit is contained in:
parent
b18a536194
commit
8e8f43e50f
3 changed files with 11 additions and 21 deletions
|
@ -144,24 +144,14 @@ namespace agg
|
|||
unsigned alpha,
|
||||
unsigned cover=0)
|
||||
{
|
||||
if (alpha)
|
||||
{
|
||||
calc_type r = p[Order::R];
|
||||
calc_type g = p[Order::G];
|
||||
calc_type b = p[Order::B];
|
||||
calc_type a = p[Order::A];
|
||||
|
||||
p[Order::A] = (value_type)(alpha + a - ((alpha * a + base_mask) >> base_shift));
|
||||
if (p[Order::A]) {
|
||||
if (!cover)
|
||||
{
|
||||
cover = base_mask;
|
||||
}
|
||||
p[Order::R] = (value_type)((cr * alpha / cover) + (r * a * (base_mask - alpha) / base_mask / p[Order::A]));
|
||||
p[Order::G] = (value_type)((cg * alpha / cover) + (g * a * (base_mask - alpha) / base_mask / p[Order::A]));
|
||||
p[Order::B] = (value_type)((cb * alpha / cover) + (b * a * (base_mask - alpha) / base_mask / p[Order::A]));
|
||||
}
|
||||
}
|
||||
calc_type r = p[Order::R];
|
||||
calc_type g = p[Order::G];
|
||||
calc_type b = p[Order::B];
|
||||
calc_type a = p[Order::A];
|
||||
p[Order::R] = (value_type)(((cr - r) * alpha + (r << base_shift)) >> base_shift);
|
||||
p[Order::G] = (value_type)(((cg - g) * alpha + (g << base_shift)) >> base_shift);
|
||||
p[Order::B] = (value_type)(((cb - b) * alpha + (b << base_shift)) >> base_shift);
|
||||
p[Order::A] = (value_type)((alpha + a) - ((alpha * a + base_mask) >> base_shift));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef agg::wrap_mode_repeat wrap_x_type;
|
||||
typedef agg::wrap_mode_repeat wrap_y_type;
|
||||
typedef agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32,
|
||||
typedef agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_plain,
|
||||
agg::row_accessor<agg::int8u>, agg::pixel32_type> rendering_buffer;
|
||||
typedef agg::image_accessor_wrap<rendering_buffer,
|
||||
wrap_x_type,
|
||||
|
@ -94,7 +94,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
unsigned h=(*pat)->height();
|
||||
agg::row_accessor<agg::int8u> pattern_rbuf((agg::int8u*)(*pat)->getBytes(),w,h,w*4);
|
||||
agg::span_allocator<agg::rgba8> sa;
|
||||
agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32,
|
||||
agg::pixfmt_alpha_blend_rgba<agg::blender_rgba32_plain,
|
||||
agg::row_accessor<agg::int8u>, agg::pixel32_type> pixf_pattern(pattern_rbuf);
|
||||
img_source_type img_src(pixf_pattern);
|
||||
|
||||
|
|
|
@ -499,7 +499,7 @@ void scale_image_bilinear8 (Image& target,const Image& source, double x_off_f, d
|
|||
template <typename Image>
|
||||
void scale_image_agg (Image& target,const Image& source, scaling_method_e scaling_method, double scale_factor, double x_off_f, double y_off_f, double filter_radius, double ratio)
|
||||
{
|
||||
typedef agg::pixfmt_rgba32 pixfmt;
|
||||
typedef agg::pixfmt_rgba32_plain pixfmt;
|
||||
typedef agg::renderer_base<pixfmt> renderer_base;
|
||||
|
||||
// define some stuff we'll use soon
|
||||
|
|
Loading…
Add table
Reference in a new issue