1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #include "generic_bitmap.hpp"
27 GenericBitmap::GenericBitmap( intf_thread_t *pIntf, int nbFrames, int fps ):
28 SkinObject( pIntf ), m_nbFrames( nbFrames ), m_frameRate( fps )
33 BitmapImpl::BitmapImpl( intf_thread_t *pIntf, int width, int height,
34 int nbFrames, int fps ):
35 GenericBitmap( pIntf, nbFrames, fps ), m_width( width ),
36 m_height( height ), m_pData( NULL )
38 m_pData = new uint8_t[width * height * 4];
39 memset( m_pData, 0, width * height * 4 );
43 BitmapImpl::~BitmapImpl()
49 bool BitmapImpl::drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
50 int xDest, int yDest, int width, int height )
52 int srcWidth = rSource.getWidth();
53 uint32_t *pSrc = (uint32_t*)rSource.getData() + ySrc * srcWidth + xSrc;
58 if( xSrc < 0 || xSrc + width > srcWidth ||
59 ySrc < 0 || ySrc + height > rSource.getHeight() )
61 msg_Warn( getIntf(), "drawBitmap: source rect too small, ignoring" );
64 if( xDest < 0 || xDest + width > m_width ||
65 yDest < 0 || yDest + height > m_height )
67 msg_Warn( getIntf(), "drawBitmap: dest rect too small, ignoring" );
71 uint32_t *pDest = (uint32_t*)m_pData + yDest * m_width + xDest ;
72 for( int y = 0; y < height; y++ )
74 memcpy( pDest, pSrc, 4 * width );