Skip to content

Commit

Permalink
fix alpha in dissolve
Browse files Browse the repository at this point in the history
For an opaque pixel in an image that is not all opaque in the middle of
the transition, it would become translucent: 0.5 + 0.5 - 0.5 * 0.5 =
0.75. When the result is composited over another image, the background
bleeds into the intersection of pixels that are opaque in each input.

See https://forum.shotcut.org/t/background-bleeds-through-transition/
46431
  • Loading branch information
ddennedy committed Nov 13, 2024
1 parent faa23e9 commit 2902592
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/modules/core/transition_luma.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* transition_luma.c -- a generic dissolve/wipe processor
* Copyright (C) 2003-2023 Meltytech, LLC
* Copyright (C) 2003-2024 Meltytech, LLC
*
* Adapted from Kino Plugin Timfx, which is
* Copyright (C) 2002 Timothy M. Shead <[email protected]>
Expand Down Expand Up @@ -60,7 +60,7 @@ static void composite_line_yuv_float(
mix_a = calculate_mix(1.0f - weight, alpha_a ? *alpha_a : 255);
mix_b = calculate_mix(weight, alpha_b ? *alpha_b : 255);
if (alpha_a) {
float mix2 = mix_b + mix_a - mix_b * mix_a;
float mix2 = mix_b + mix_a;
*alpha_a = 255 * mix2;
if (mix2 != 0.f)
mix_b /= mix2;
Expand Down

0 comments on commit 2902592

Please sign in to comment.