summaryrefslogtreecommitdiffstats
path: root/libass
diff options
context:
space:
mode:
authoreugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-16 19:01:56 +0000
committereugeni <eugeni@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-16 19:01:56 +0000
commit5cdc829b9f2ca39f6032ddbeafbc27ca51d7b2fc (patch)
treee15a43bb738d1c89bf6850af150808ce54cd26d7 /libass
parent565cfd4200821b052c6f014576d11385da543566 (diff)
downloadmpv-5cdc829b9f2ca39f6032ddbeafbc27ca51d7b2fc.tar.bz2
mpv-5cdc829b9f2ca39f6032ddbeafbc27ca51d7b2fc.tar.xz
Subtract glyph bitmap from outline bitmap.
It greatly improves display of glyphs with semitransparent primary color. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19862 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libass')
-rw-r--r--libass/ass_bitmap.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index c7d5f786aa..a2ab88e8d4 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -159,6 +159,25 @@ static bitmap_t* glyph_to_bitmap_internal(FT_Glyph glyph, int bord)
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 @@ int glyph_to_bitmap(ass_synth_priv_t* priv, FT_Glyph glyph, FT_Glyph outline_gly
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;
}