[release] version bump to 13.0 beta1
[vuplus_xbmc] / xbmc / guilib / AnimatedGif.h
1 /*!
2 \file AnimatedGif.h
3 \brief
4 */
5
6
7 // ****************************************************************************
8 //
9 // WINIMAGE.H : Generic classes for raster images (MSWindows specialization)
10 //
11 //  Content: Class declarations of:
12 //  - class CAnimatedGif             : Storage class for single images
13 //  - class CAnimatedGifSet          : Storage class for sets of images
14 //  - class C_AnimationWindow   : Window Class to display animations
15 //
16 //  (Includes declarations of routines to Load and Save BMP files and to load
17 // GIF files into these classes).
18 //
19 //  --------------------------------------------------------------------------
20 //
21 // Copyright (c) 2000, Juan Soulie <jsoulie@cplusplus.com>
22 //
23 // Permission to use, copy, modify, distribute and sell this software or any
24 // part thereof and/or its documentation for any purpose is granted without fee
25 // provided that the above copyright notice and this permission notice appear
26 // in all copies.
27 //
28 // This software is provided "as is" without express or implied warranty of
29 // any kind. The author shall have no liability with respect to the
30 // infringement of copyrights or patents that any modification to the content
31 // of this file or this file itself may incur.
32 //
33 // ****************************************************************************
34
35
36 #include "Texture.h" // for COLOR
37
38 #pragma pack(1)
39
40 /*!
41  \ingroup textures
42  \brief
43  */
44 typedef struct tagGUIRGBQUAD
45 {
46   BYTE rgbBlue;
47   BYTE rgbGreen;
48   BYTE rgbRed;
49   BYTE rgbReserved;
50 }
51 GUIRGBQUAD;
52
53 /*!
54  \ingroup textures
55  \brief
56  */
57 typedef struct tagGUIBITMAPINFOHEADER
58 {
59   DWORD biSize;
60   LONG biWidth;
61   LONG biHeight;
62   WORD biPlanes;
63   WORD biBitCount;
64   DWORD biCompression;
65   DWORD biSizeImage;
66   LONG biXPelsPerMeter;
67   LONG biYPelsPerMeter;
68   DWORD biClrUsed;
69   DWORD biClrImportant;
70 }
71 GUIBITMAPINFOHEADER;
72
73 /*!
74  \ingroup textures
75  \brief
76  */
77 typedef struct tagGUIBITMAPINFO
78 {
79     GUIBITMAPINFOHEADER    bmiHeader;
80     GUIRGBQUAD                                           bmiColors[1];
81 } GUIBITMAPINFO;
82
83 #pragma pack()
84
85
86 // ****************************************************************************
87 // * CAnimatedGif                                                                  *
88 // *    Storage class for single images                                       *
89 // ****************************************************************************
90 /*!
91  \ingroup textures
92  \brief Storage class for single images
93  */
94 class CAnimatedGif
95 {
96 public:
97   CAnimatedGif();
98   virtual ~CAnimatedGif();
99
100   // standard members:
101   int Width, Height;   ///< Dimensions in pixels
102   int BPP;        // Bits Per Pixel
103   char* Raster;       ///< Bits of Raster Data (Byte Aligned)
104   COLOR* Palette;      ///< Color Map
105   int BytesPerRow;    ///< Width (in bytes) including alignment!
106   int Transparent;    ///< Index of Transparent color (-1 for none)
107
108   // Extra members for animations:
109   int nLoops;
110   int xPos, yPos;     ///< Relative Position
111   int Delay;       ///< Delay after image in 1/1000 seconds.
112   int Transparency;    ///< Animation Transparency.
113   // Windows GDI specific:
114   GUIBITMAPINFO* pbmi;        ///< BITMAPINFO structure
115
116   // constructor and destructor:
117
118   // operator= (object copy)
119   CAnimatedGif& operator= (CAnimatedGif& rhs);
120
121   /// \brief Image initializer (allocates space for raster and palette):
122   void Init (int iWidth, int iHeight, int iBPP, int iLoops = 0);
123
124   inline char& Pixel (int x, int y) { return Raster[y*BytesPerRow + x];}
125
126 };
127
128 // ****************************************************************************
129 // * CAnimatedGifSet                                                               *
130 // *    Storage class for sets of images                                      *
131 // ****************************************************************************
132 /*!
133  \ingroup textures
134  \brief Storage class for sets of images
135  */
136 class CAnimatedGifSet
137 {
138 public:
139
140   // constructor and destructor:
141   CAnimatedGifSet();
142   virtual ~CAnimatedGifSet();
143
144   int FrameWidth, FrameHeight; ///< Dimensions of ImageSet in pixels.
145   int nLoops;          // Number of Loops (0 = infinite)
146
147   std::vector<CAnimatedGif*> m_vecimg;        ///< Images' Vector.
148
149   void AddImage (CAnimatedGif*);   ///< Append new image to vector (push_back)
150
151   int GetImageCount() const;
152   // File Formats:
153   int LoadGIF (const char* szFile);
154
155   void Release();
156 protected:
157   static unsigned char getbyte(FILE *fd);
158 };
159