summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-09-10 11:08:21 +0200
committerGrigori Goronzy <greg@blackbox>2009-09-16 02:36:20 +0200
commit69b167d70bc918d2e8749c8119efe4753214f668 (patch)
tree08ff22952d86060f0116ec58637c1db4e6c66ac5
parent33a3ab2c8777241b73ad85024158e19fb1f9c699 (diff)
downloadlibass-69b167d70bc918d2e8749c8119efe4753214f668.tar.bz2
libass-69b167d70bc918d2e8749c8119efe4753214f668.tar.xz
Copy shadow bitmap from glyph bitmap
It's not necessary to create the shadow bitmap by adding the glyph bitmap to the outline bitmap; the outline is a superset of the glyph.
-rw-r--r--libass/ass_bitmap.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c
index 1ae2d7c..c7c039d 100644
--- a/libass/ass_bitmap.c
+++ b/libass/ass_bitmap.c
@@ -230,12 +230,12 @@ static Bitmap *glyph_to_bitmap_internal(ASS_Library *library,
}
/**
- * \brief fix outline bitmap and generate shadow bitmap
- * Two things are done here:
- * 1. Glyph bitmap is subtracted from outline bitmap. This way looks much better in some cases.
- * 2. Shadow bitmap is created as a sum of glyph and outline bitmaps.
+ * \brief fix outline bitmap
+ *
+ * The glyph bitmap is subtracted from outline bitmap. This way looks much
+ * better in some cases.
*/
-static Bitmap *fix_outline_and_shadow(Bitmap *bm_g, Bitmap *bm_o)
+static void fix_outline(Bitmap *bm_g, Bitmap *bm_o)
{
int x, y;
const int l = bm_o->left > bm_g->left ? bm_o->left : bm_g->left;
@@ -247,14 +247,10 @@ static Bitmap *fix_outline_and_shadow(Bitmap *bm_g, Bitmap *bm_o)
bm_o->top + bm_o->h <
bm_g->top + bm_g->h ? bm_o->top + bm_o->h : bm_g->top + bm_g->h;
- Bitmap *bm_s = copy_bitmap(bm_o);
-
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);
- unsigned char *s =
- bm_s->buffer + (t - bm_s->top) * bm_s->w + (l - bm_s->left);
for (y = 0; y < b - t; ++y) {
for (x = 0; x < r - l; ++x) {
@@ -262,15 +258,10 @@ static Bitmap *fix_outline_and_shadow(Bitmap *bm_g, Bitmap *bm_o)
c_g = g[x];
c_o = o[x];
o[x] = (c_o > c_g) ? c_o - (c_g / 2) : 0;
- s[x] = (c_o < 0xFF - c_g) ? c_o + c_g : 0xFF;
}
g += bm_g->w;
o += bm_o->w;
- s += bm_s->w;
}
-
- assert(bm_s);
- return bm_s;
}
/**
@@ -528,16 +519,19 @@ int glyph_to_bitmap(ASS_Library *library, ASS_SynthPriv *priv_blur,
priv_blur->g_w);
}
- if (*bm_o && border_style == 3)
+ // Create shadow and fix outline as needed
+ if (*bm_o && border_style != 3) {
*bm_s = copy_bitmap(*bm_o);
- else if (*bm_o)
- *bm_s = fix_outline_and_shadow(*bm_g, *bm_o);
- else
+ fix_outline(*bm_g, *bm_o);
+ } else if (*bm_o) {
+ *bm_s = copy_bitmap(*bm_o);
+ } else
*bm_s = copy_bitmap(*bm_g);
+ assert(bm_s);
+
shift_bitmap((*bm_s)->buffer, (*bm_s)->w,(*bm_s)->h,
shadow_offset.x, shadow_offset.y);
- assert(bm_s);
return 0;
}