1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2003 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@via.ecp.fr>
8 * Olivier Teulière <ipkiss@via.ecp.fr>
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.
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.
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 *****************************************************************************/
25 #ifndef GENERIC_BITMAP_HPP
26 #define GENERIC_BITMAP_HPP
28 #include "skin_common.hpp"
29 #include "../utils/pointer.hpp"
30 #include "../utils/position.hpp"
33 /// Generic interface for bitmaps
34 class GenericBitmap: public SkinObject, public Box
37 virtual ~GenericBitmap() {}
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;
43 /// Get the number of frames in the bitmap
44 int getNbFrames() const { return m_nbFrames; }
46 /// Get the number of frames per second (for animated bitmaps)
47 int getFrameRate() const { return m_frameRate; }
50 GenericBitmap( intf_thread_t *pIntf, int nbFrames = 1, int fps = 0);
60 /// Basic bitmap implementation
61 class BitmapImpl: public GenericBitmap
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 );
69 /// Get the width of the bitmap
70 virtual int getWidth() const { return m_width; }
72 /// Get the heighth of the bitmap
73 virtual int getHeight() const { return m_height; }
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; }
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 );
84 /// Size of the bitmap.
85 int m_width, m_height;
86 /// Buffer containing the image data.
91 typedef CountedPtr<GenericBitmap> GenericBitmapPtr;