]> git.sesse.net Git - vlc/blob - modules/gui/skins2/src/generic_bitmap.hpp
Remove useless vlc_object_detach() before vlc_object_release()
[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 along
21  * with this program; if not, write to the Free Software Foundation, Inc.,
22  * 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     /// Get the number of Loops (for animated bitmaps)
50     int getNbLoops() const { return m_nbLoops; }
51
52 protected:
53     GenericBitmap( intf_thread_t *pIntf, int nbFrames = 1, int fps = 0, int nbLoops = 0);
54
55 private:
56     /// Number of frames
57     int m_nbFrames;
58     /// Frame rate
59     int m_frameRate;
60     /// Number of Loops
61     int m_nbLoops;
62 };
63
64
65 /// Basic bitmap implementation
66 class BitmapImpl: public GenericBitmap
67 {
68 public:
69     /// Create an empty bitmap of the given size
70     BitmapImpl( intf_thread_t *pIntf, int width, int height,
71                 int nbFrames = 1, int fps = 0, int nbLoops = 0 );
72     ~BitmapImpl();
73
74     /// Get the width of the bitmap
75     virtual int getWidth() const { return m_width; }
76
77     /// Get the heighth of the bitmap
78     virtual int getHeight() const { return m_height; }
79
80     /// Get a linear buffer containing the image data.
81     /// Each pixel is stored in 4 bytes in the order B,G,R,A
82     virtual uint8_t *getData() const { return m_pData; }
83
84     // Copy a region of another bitmap on this bitmap
85     bool drawBitmap( const GenericBitmap &rSource, int xSrc, int ySrc,
86                      int xDest, int yDest, int width, int height );
87
88 private:
89     /// Size of the bitmap.
90     int m_width, m_height;
91     /// Buffer containing the image data.
92     uint8_t *m_pData;
93 };
94
95
96 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;
97
98 #endif