]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_bitmap.hpp
3a803a3f4e800cbfa634e30c56b5910316fe521f
[vlc] / modules / gui / skins2 / src / generic_bitmap.hpp
1 /*****************************************************************************
2  * generic_bitmap.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef GENERIC_BITMAP_HPP
26 #define GENERIC_BITMAP_HPP
27
28 #include "skin_common.hpp"
29 #include "../utils/pointer.hpp"
30 #include "../utils/position.hpp"
31
32
33 /// Generic interface for bitmaps
34 class GenericBitmap: public SkinObject, public Box
35 {
36     public:
37         virtual ~GenericBitmap() {}
38
39         /// Get a linear buffer containing the image data.
40         /// Each pixel is stored in 4 bytes in the order B,G,R,A
41         virtual uint8_t *getData() const = 0;
42
43         /// Get the number of frames in the bitmap
44         int getNbFrames() const { return m_nbFrames; }
45
46         /// Get the number of frames per second (for animated bitmaps)
47         int getFrameRate() const { return m_frameRate; }
48
49     protected:
50         GenericBitmap( intf_thread_t *pIntf, int nbFrames = 1, int fps = 0);
51
52     private:
53         /// Number of frames
54         int m_nbFrames;
55         /// Frame rate
56         int m_frameRate;
57 };
58
59
60 /// Basic bitmap implementation
61 class BitmapImpl: public GenericBitmap
62 {
63     public:
64         /// Create an empty bitmap of the given size
65         BitmapImpl( intf_thread_t *pIntf, int width, int height,
66                     int nbFrames = 1, int fps = 0 );
67         ~BitmapImpl();
68
69         /// Get the width of the bitmap
70         virtual int getWidth() const { return m_width; }
71
72         /// Get the heighth of the bitmap
73         virtual int getHeight() const { return m_height; }
74
75         /// Get a linear buffer containing the image data.
76         /// Each pixel is stored in 4 bytes in the order B,G,R,A
77         virtual uint8_t *getData() const { return m_pData; }
78
79         // Copy a region of another bitmap on this bitmap
80         bool drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
81                          int xDest, int yDest, int width, int height );
82
83     private:
84         /// Size of the bitmap.
85         int m_width, m_height;
86         /// Buffer containing the image data.
87         uint8_t *m_pData;
88 };
89
90
91 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
92
93 #endif