changeset 19406:747a5c394a69

Fix wrong handling of transparency in \fad(\fade).
author eugeni
date Wed, 16 Aug 2006 00:54:59 +0000
parents 0797e1b4a4be
children c3dc9a93f56e
files libass/ass_render.c
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_render.c	Tue Aug 15 22:46:56 2006 +0000
+++ b/libass/ass_render.c	Wed Aug 16 00:54:59 2006 +0000
@@ -570,6 +570,17 @@
 	*var = (_r(*var) << 24) + (_g(*var) << 16) + (_b(*var) << 8) + (_a(*var) * (1 - pwr) + _a(new) * pwr);
 }
 
+/**
+ * \brief Multiply two alpha values
+ * \param a first value
+ * \param b second value
+ * \return result of multiplication
+ * Parameters and result are limited by 0xFF.
+ */
+static uint32_t mult_alpha(uint32_t a, uint32_t b)
+{
+	return 0xFF - (0xFF - a) * (0xFF - b) / 0xFF;
+}
 
 /**
  * \brief Calculate alpha value by piecewise linear function
@@ -596,10 +607,10 @@
 	}
 
 
-	change_alpha(&render_context.c1, a, 1.);
-	change_alpha(&render_context.c2, a, 1.);
-	change_alpha(&render_context.c3, a, 1.);
-	change_alpha(&render_context.c4, a, 1.);
+	change_alpha(&render_context.c1, mult_alpha(_a(render_context.c1), a), 1.);
+	change_alpha(&render_context.c2, mult_alpha(_a(render_context.c2), a), 1.);
+	change_alpha(&render_context.c3, mult_alpha(_a(render_context.c3), a), 1.);
+	change_alpha(&render_context.c4, mult_alpha(_a(render_context.c4), a), 1.);
 }
 
 /**