Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.2 backport] Fix opacity calculation problem with the agg renderer (#5697) #7087

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1324,7 +1324,7 @@ int aggCompositeRasterBuffer(imageObj *dest, rasterBufferObj *overlay,
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 All @@ -1350,12 +1350,13 @@ int aggCompositeRasterBuffer(imageObj *dest, rasterBufferObj *overlay,
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;
#endif
Expand Down
Loading