Skip to content

Commit

Permalink
Fix opacity calculation problem with the agg renderer (#5697) (#7085)
Browse files Browse the repository at this point in the history
Fixes #56974
  • Loading branch information
szekerest committed Jun 21, 2024
1 parent 5f6f317 commit a8f6aca
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 3 deletions.
Binary file modified msautotest/renderers/expected/compop_hsl_color.agg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/renderers/expected/compop_hsl_hue.agg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/renderers/expected/compop_hsl_luminosity.agg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified msautotest/renderers/expected/compositing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions src/mapagg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1345,7 +1345,7 @@ static int aggCompositeRasterBufferPixman(imageObj *dest,
if (opacity == 100) {
alpha_mask_i_ptr = NULL;
} else {
unsigned char alpha = (unsigned char)(opacity * 2.55);
unsigned char alpha = (unsigned char)(MS_NINT(opacity * 2.55));
if (!alpha_mask_i) {
alpha_mask = (unsigned char *)msSmallMalloc(dest->width * dest->height);
alpha_mask_i =
Expand Down Expand Up @@ -1379,12 +1379,13 @@ static int aggCompositeRasterBufferNoPixman(imageObj *dest,
pixel_format pf(b);
mapserver::comp_op_e comp_op = ms2agg_compop(comp);
if (comp_op == mapserver::comp_op_src_over) {
r->m_renderer_base.blend_from(pf, 0, 0, 0, unsigned(opacity * 2.55));
r->m_renderer_base.blend_from(pf, 0, 0, 0,
unsigned(MS_NINT(opacity * 2.55)));
} else {
compop_pixel_format pixf(r->m_rendering_buffer);
compop_renderer_base ren(pixf);
pixf.comp_op(comp_op);
ren.blend_from(pf, 0, 0, 0, unsigned(opacity * 2.55));
ren.blend_from(pf, 0, 0, 0, unsigned(MS_NINT(opacity * 2.55)));
}
return MS_SUCCESS;
}
Expand Down

0 comments on commit a8f6aca

Please sign in to comment.