# HG changeset patch # User eugeni # Date 1158970500 0 # Node ID 66d444e5ec8df526c6a389eed92b24f8f29c6e3f # Parent fb2063eaa445f5cc7a89356307d7f158a43a6869 Better fix_outline implementation. No more "fix_outline failed" messages, should work even with the craziest glyphs. diff -r fb2063eaa445 -r 66d444e5ec8d libass/ass_bitmap.c --- a/libass/ass_bitmap.c Fri Sep 22 20:47:08 2006 +0000 +++ b/libass/ass_bitmap.c Sat Sep 23 00:15:00 2006 +0000 @@ -162,20 +162,23 @@ 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; + const int l = bm_o->left > bm_g->left ? bm_o->left : bm_g->left; + const int t = bm_o->top > bm_g->top ? bm_o->top : bm_g->top; + const int r = bm_o->left + bm_o->w < bm_g->left + bm_g->w ? bm_o->left + bm_o->w : bm_g->left + bm_g->w; + const int b = bm_o->top + bm_o->h < bm_g->top + bm_g->h ? bm_o->top + bm_o->h : bm_g->top + bm_g->h; + unsigned char* g = bm_g->buffer + (t - bm_g->top) * bm_g->w + (l - bm_g->left); + unsigned char* o = bm_o->buffer + (t - bm_o->top) * bm_o->w + (l - bm_o->left); + + for (y = 0; y < b - t; ++y) { + for (x = 0; x < r - l; ++x) { + unsigned char c_g, c_o; + c_g = g[x]; + c_o = o[x]; + o[x] = (c_o > c_g) ? c_o - c_g : 0; + } + g += bm_g->w; + o += bm_o->w; } - 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)