changeset 19856:b4cb97ef9d20

Subtract glyph bitmap from outline bitmap. It greatly improves display of glyphs with semitransparent primary color.
author eugeni
date Sat, 16 Sep 2006 19:01:56 +0000
parents bf4bd549e4b2
children 1f1671bc9ab2
files libass/ass_bitmap.c
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libass/ass_bitmap.c	Sat Sep 16 17:58:30 2006 +0000
+++ b/libass/ass_bitmap.c	Sat Sep 16 19:01:56 2006 +0000
@@ -159,6 +159,25 @@
 	return bm;
 }
 
+static void fix_outline(bitmap_t* bm_g, bitmap_t* bm_o)
+{
+	int x, y;
+	int sx = bm_g->left - bm_o->left;
+	int sy = bm_g->top - bm_o->top;
+	if (sx < 0 || sy < 0) {
+		mp_msg(MSGT_GLOBAL, MSGL_WARN, "fix_outline failed  \n");
+		return;
+	}
+	for (y = 0; y < bm_g->h; ++y)
+		for (x = 0; x < bm_g->w; ++x) {
+			unsigned char c_g, c_o;
+			c_o = bm_o->buffer[(y + sy) * bm_o->w + (x + sx)];
+			c_g = bm_g->buffer[y * bm_g->w + x];
+			bm_o->buffer[(y + sy) * bm_o->w + (x + sx)] = (c_o > c_g) ? c_o - c_g : 0;
+		}
+	
+}
+
 int glyph_to_bitmap(ass_synth_priv_t* priv, FT_Glyph glyph, FT_Glyph outline_glyph, bitmap_t** bm_g, bitmap_t** bm_o, int be)
 {
 	const int bord = ceil(blur_radius);
@@ -187,6 +206,9 @@
 			blur((*bm_o)->buffer, priv->tmp, (*bm_o)->w, (*bm_o)->h, (*bm_o)->w, (int*)priv->gt2, priv->g_r, priv->g_w);
 	}
 
+	if (bm_o)
+		fix_outline(*bm_g, *bm_o);
+
 	return 0;
 }