generic_bitmap.hpp

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * generic_bitmap.hpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
00008  *          Olivier Teulière <ipkiss@via.ecp.fr>
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef GENERIC_BITMAP_HPP
00026 #define GENERIC_BITMAP_HPP
00027 
00028 #include "skin_common.hpp"
00029 #include "../utils/pointer.hpp"
00030 #include "../utils/position.hpp"
00031 
00032 
00033 /// Generic interface for bitmaps
00034 class GenericBitmap: public SkinObject, public Box
00035 {
00036     public:
00037         virtual ~GenericBitmap() {}
00038 
00039         /// Get a linear buffer containing the image data.
00040         /// Each pixel is stored in 4 bytes in the order B,G,R,A
00041         virtual uint8_t *getData() const = 0;
00042 
00043         /// Get the number of frames in the bitmap
00044         int getNbFrames() const { return m_nbFrames; }
00045 
00046         /// Get the number of frames per second (for animated bitmaps)
00047         int getFrameRate() const { return m_frameRate; }
00048 
00049     protected:
00050         GenericBitmap( intf_thread_t *pIntf, int nbFrames = 1, int fps = 0);
00051 
00052     private:
00053         /// Number of frames
00054         int m_nbFrames;
00055         /// Frame rate
00056         int m_frameRate;
00057 };
00058 
00059 
00060 /// Basic bitmap implementation
00061 class BitmapImpl: public GenericBitmap
00062 {
00063     public:
00064         /// Create an empty bitmap of the given size
00065         BitmapImpl( intf_thread_t *pIntf, int width, int height,
00066                     int nbFrames = 1, int fps = 0 );
00067         ~BitmapImpl();
00068 
00069         /// Get the width of the bitmap
00070         virtual int getWidth() const { return m_width; }
00071 
00072         /// Get the heighth of the bitmap
00073         virtual int getHeight() const { return m_height; }
00074 
00075         /// Get a linear buffer containing the image data.
00076         /// Each pixel is stored in 4 bytes in the order B,G,R,A
00077         virtual uint8_t *getData() const { return m_pData; }
00078 
00079         // Copy a region of another bitmap on this bitmap
00080         bool drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
00081                          int xDest, int yDest, int width, int height );
00082 
00083     private:
00084         /// Size of the bitmap.
00085         int m_width, m_height;
00086         /// Buffer containing the image data.
00087         uint8_t *m_pData;
00088 };
00089 
00090 
00091 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
00092 
00093 #endif

Generated on Wed Aug 13 08:02:38 2008 for VLC by  doxygen 1.5.1