vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Sat Nov 9 16:29:20 2013 +0200| [e9f42c6b0061aa22536e1e9e5aca6016782a2e38] | committer: Rémi Denis-Courmont
FreeType: add ARGB support > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e9f42c6b0061aa22536e1e9e5aca6016782a2e38 --- modules/text_renderer/freetype.c | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/modules/text_renderer/freetype.c b/modules/text_renderer/freetype.c index d4269e6..989ea58 100644 --- a/modules/text_renderer/freetype.c +++ b/modules/text_renderer/freetype.c @@ -365,6 +365,7 @@ static void RGBFromRGB( uint32_t i_argb, *pi_g = ( i_argb & 0x0000ff00 ) >> 8; *pi_b = ( i_argb & 0x000000ff ); } + /***************************************************************************** * Make any TTF/OTF fonts present in the attachments of the media file * and store them for later use by the FreeType Engine @@ -1005,6 +1006,47 @@ static inline void BlendRGBAPixel( picture_t *p_picture, } } +static void FillARGBPicture(picture_t *pic, int a, int r, int g, int b) +{ + for (int dy = 0; dy < pic->p->i_visible_lines; dy++) + { + for (int dx = 0; dx < pic->p->i_visible_pitch; dx += 4) + { + uint8_t *rgba = &pic->p->p_pixels[dy * pic->p->i_pitch + dx]; + rgba[0] = a; + rgba[1] = r; + rgba[2] = g; + rgba[3] = b; + } + } +} + +static inline void BlendARGBPixel(picture_t *pic, int pic_x, int pic_y, + int a, int r, int g, int b, int alpha) +{ + uint8_t *rgba = &pic->p->p_pixels[pic_y * pic->p->i_pitch + 4 * pic_x]; + int an = a * alpha / 255; + int ao = rgba[3]; + + if (ao == 0) + { + rgba[0] = an; + rgba[1] = r; + rgba[2] = g; + rgba[3] = b; + } + else + { + rgba[0] = 255 - (255 - rgba[0]) * (255 - an) / 255; + if (rgba[0] != 0) + { + rgba[1] = (rgba[1] * ao * (255 - an) / 255 + r * an ) / rgba[0]; + rgba[2] = (rgba[2] * ao * (255 - an) / 255 + g * an ) / rgba[0]; + rgba[3] = (rgba[3] * ao * (255 - an) / 255 + b * an ) / rgba[0]; + } + } +} + static inline void BlendAXYZGlyph( picture_t *p_picture, int i_picture_x, int i_picture_y, int i_a, int i_x, int i_y, int i_z, @@ -2092,6 +2134,11 @@ static int RenderCommon( filter_t *p_filter, subpicture_region_t *p_region_out, RGBFromRGB, FillRGBAPicture, BlendRGBAPixel ); + else if( *p_chroma == VLC_CODEC_ARGB ) + rv = RenderAXYZ( p_filter, p_region_out, p_lines, &bbox, + i_margin, *p_chroma, RGBFromRGB, + FillARGBPicture, BlendARGBPixel ); + if( !rv ) break; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
