Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

ft2_bitmap.cpp

00001 /*****************************************************************************
00002  * ft2_bitmap.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: ft2_bitmap.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *          Olivier Teulière <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 #include "ft2_bitmap.hpp"
00026 
00027 
00028 FT2Bitmap::FT2Bitmap( intf_thread_t *pIntf, int width, int height ):
00029     GenericBitmap( pIntf ), m_width( width ), m_height( height )
00030 {
00031     // Allocate memory for the buffer
00032     m_pData = new uint8_t[m_height * m_width * 4];
00033     memset( m_pData, 0, m_height * m_width * 4 );
00034 }
00035 
00036 
00037 FT2Bitmap::~FT2Bitmap()
00038 {
00039     if( m_pData )
00040     {
00041         delete[] m_pData;
00042     }
00043 }
00044 
00045 
00046 void FT2Bitmap::draw( const FT_Bitmap &rBitmap, int left, int top,
00047                       uint32_t color )
00048 {
00049     uint8_t *pBuf = rBitmap.buffer;
00050 
00051     // Calculate colors
00052     uint8_t blue = color & 0xff;
00053     uint8_t green = (color >> 8) & 0xff;
00054     uint8_t red = (color >> 16) & 0xff;
00055 
00056     for( int y = top; y < top + rBitmap.rows; y++ )
00057     {
00058         uint8_t *pData = m_pData + 4 * (m_width * y + left);
00059         for( int x = left; x < left + rBitmap.width; x++ )
00060         {
00061             // The buffer in FT_Bitmap contains alpha values
00062             uint8_t val = *(pBuf++);
00063             *(pData++) = (blue * val) >> 8;
00064             *(pData++) = (green * val) >> 8;
00065             *(pData++) = (red * val) >> 8;
00066             *(pData++) = val;
00067         }
00068     }
00069 }
00070 
00071 

Generated on Tue Dec 20 10:14:42 2005 for vlc-0.8.4a by  doxygen 1.4.2