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: 800a8a0828b9a2e72f43a42ba775fef0afa10726 $
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 along
00021  * with this program; if not, write to the Free Software Foundation, Inc.,
00022  * 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     /// Get the number of Loops (for animated bitmaps)
00050     int getNbLoops() const { return m_nbLoops; }
00051 
00052 protected:
00053     GenericBitmap( intf_thread_t *pIntf, int nbFrames = 1, int fps = 0, int nbLoops = 0);
00054 
00055 private:
00056     /// Number of frames
00057     int m_nbFrames;
00058     /// Frame rate
00059     int m_frameRate;
00060     /// Number of Loops
00061     int m_nbLoops;
00062 };
00063 
00064 
00065 /// Basic bitmap implementation
00066 class BitmapImpl: public GenericBitmap
00067 {
00068 public:
00069     /// Create an empty bitmap of the given size
00070     BitmapImpl( intf_thread_t *pIntf, int width, int height,
00071                 int nbFrames = 1, int fps = 0, int nbLoops = 0 );
00072     ~BitmapImpl();
00073 
00074     /// Get the width of the bitmap
00075     virtual int getWidth() const { return m_width; }
00076 
00077     /// Get the heighth of the bitmap
00078     virtual int getHeight() const { return m_height; }
00079 
00080     /// Get a linear buffer containing the image data.
00081     /// Each pixel is stored in 4 bytes in the order B,G,R,A
00082     virtual uint8_t *getData() const { return m_pData; }
00083 
00084     // Copy a region of another bitmap on this bitmap
00085     bool drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
00086                      int xDest, int yDest, int width, int height );
00087 
00088 private:
00089     /// Size of the bitmap.
00090     int m_width, m_height;
00091     /// Buffer containing the image data.
00092     uint8_t *m_pData;
00093 };
00094 
00095 
00096 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
00097 
00098 #endif

Generated on Tue May 25 08:04:58 2010 for VLC by  doxygen 1.5.6