[vlc-devel] Re: Please help in blending routine

Sigmund Augdal sigmunau at stud.ntnu.no
Fri Jan 2 16:15:26 CET 2004


On Fri, Jan 02, 2004 at 09:48:34AM -0500, R. Bernstein wrote:
> Many thanks for offering to help. It looks like there is much work to
> be done here. Given the treacherous nature of things (I make small
> changes which alter things drastically in ways I don't fully
> understand), I'll probably make lots of incremental
> changes. Ultimately it would be nice to have a general-purpose bitmap
> format with a general purpose scaling and blending routine. But
> initially, I think that is going to be too hard (for me) to do.
I whould rather have general purpose routines that can take any kind of
bitmap and convert/blend/blit/scale etc. I will try to help work towards
that goal.


> A specific question the UV planes in freetype.c, this code concerning
> the UV planes, in this code:
> 
>                 for( i = 0; p_line->pp_glyphs[i] != NULL; i++ )
>                 {
>                     FT_BitmapGlyph p_glyph = p_line->pp_glyphs[ i ];
> #define alpha p_vout->p_text_renderer_data->pi_gamma[ p_glyph->bitmap.buffer[ ( x + y * p_glyph->bitmap.width ) ] ]
> #define pixel p_in[ ( ( p_line->p_glyph_pos[ i ].y >> 1 ) + pen_y + ( y >> 1 ) -  ( p_glyph->top >> 1 ) ) * i_pic_pitch + ( x >> 1 ) + pen_x + ( p_line->p_glyph_pos[ i ].x >> 1 ) + ( p_glyph->left >>1) ]
>                     for( y = 0; y < p_glyph->bitmap.rows; y+=2 )
>                     {
>                         for( x = 0; x < p_glyph->bitmap.width; x+=2 )
>                         {
>                             pixel = ( ( pixel * ( 0xFF - alpha ) ) >> 8 ) +
>                                 ( 0x80 * alpha >> 8 );
> 
> For the above pixel = ... to be correct, I gather the glyph data is
> already encoded using 4-bits per byte in the UV planes. Right? I'm not
> sure I understand the "0x80 * alpha >> 8" part. Let's how does C
> precidence work - I guess we do the multiplication first and then the
> shift. Why the multiplication by 0x80 first? Is 0x80 some color value?
0x80 is the "no-color" value. Basically to do grayscale in yuv you use the y
plane as grayscale and set the U and V planes to 0x80. The pixel = quation
is supposed to set the pixel value to a value between it's original value
and 0x80 lineary dependant on the alpha value which is a 8 bit transparency
level.
> 
> I will try to log on IRC the 7th but more likely on the weekend say the
> 10th, usually morning for me - somewhere in the range 12:00-1400 UTC.
Hope to meet you then.

Sigmund

-- 
This is the vlc-devel mailing-list, see http://www.videolan.org/vlc/
To unsubscribe, please read http://developers.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>



More information about the vlc-devel mailing list