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