comparison libass/ass_bitmap.c @ 19941:66d444e5ec8d

Better fix_outline implementation. No more "fix_outline failed" messages, should work even with the craziest glyphs.
author eugeni
date Sat, 23 Sep 2006 00:15:00 +0000
parents 98d32b832c3a
children 2792de2ca069
comparison
equal deleted inserted replaced
19940:fb2063eaa445 19941:66d444e5ec8d
160 } 160 }
161 161
162 static void fix_outline(bitmap_t* bm_g, bitmap_t* bm_o) 162 static void fix_outline(bitmap_t* bm_g, bitmap_t* bm_o)
163 { 163 {
164 int x, y; 164 int x, y;
165 int sx = bm_g->left - bm_o->left; 165 const int l = bm_o->left > bm_g->left ? bm_o->left : bm_g->left;
166 int sy = bm_g->top - bm_o->top; 166 const int t = bm_o->top > bm_g->top ? bm_o->top : bm_g->top;
167 if (sx < 0 || sy < 0) { 167 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;
168 mp_msg(MSGT_GLOBAL, MSGL_WARN, "fix_outline failed \n"); 168 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;
169 return; 169 unsigned char* g = bm_g->buffer + (t - bm_g->top) * bm_g->w + (l - bm_g->left);
170 } 170 unsigned char* o = bm_o->buffer + (t - bm_o->top) * bm_o->w + (l - bm_o->left);
171 for (y = 0; y < bm_g->h; ++y) 171
172 for (x = 0; x < bm_g->w; ++x) { 172 for (y = 0; y < b - t; ++y) {
173 for (x = 0; x < r - l; ++x) {
173 unsigned char c_g, c_o; 174 unsigned char c_g, c_o;
174 c_o = bm_o->buffer[(y + sy) * bm_o->w + (x + sx)]; 175 c_g = g[x];
175 c_g = bm_g->buffer[y * bm_g->w + x]; 176 c_o = o[x];
176 bm_o->buffer[(y + sy) * bm_o->w + (x + sx)] = (c_o > c_g) ? c_o - c_g : 0; 177 o[x] = (c_o > c_g) ? c_o - c_g : 0;
177 } 178 }
178 179 g += bm_g->w;
180 o += bm_o->w;
181 }
179 } 182 }
180 183
181 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) 184 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)
182 { 185 {
183 const int bord = ceil(blur_radius); 186 const int bord = ceil(blur_radius);