-
Notifications
You must be signed in to change notification settings - Fork 6
/
GUIImage.h
67 lines (40 loc) · 1.59 KB
/
GUIImage.h
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
#ifndef GUIIMAGE_H
#define GUIIMAGE_H
#include <string>
#include <map>
#include "Compatibility.h"
extern const SDL_Color default_color_key_c;
class GUIImage {
public:
GUIImage() : sdl_impl(0) {}
GUIImage(int w, int h, bool alpha = false, const SDL_Color& color_key =default_color_key_c);
explicit GUIImage(SDL_Surface*);
GUIImage(std::string filename, bool alpha = false, const SDL_Color& color_key =default_color_key_c);
~GUIImage();
GUIImage(const GUIImage&);
GUIImage& operator= (const GUIImage&);
static GUIImage* get_image(std::string filename, bool alpha = false, const SDL_Color& color_key =default_color_key_c);
static GUIImage create_blank(int w, int h);
static GUIImage create_filled(int w, int h, SDL_Color color);
static GUIImage create_clear(int w, int h);
static GUIImage create_outline(int w, int h, int width, SDL_Color color);
static GUIImage create_copy(const SDL_Surface*); // copy constructor
operator SDL_Surface*() const {return sdl_impl;}
SDL_Surface* operator->() const {return sdl_impl;}
void display(SDL_Surface* dest, int x, int y);
void clear();
int getw() const { return sdl_impl->w; }
int geth() const { return sdl_impl->h; }
void set_alpha(Uint32);
Uint32 get_Alpha() const;
SDL_Color get_clear_color() const;
// returns true if pixel at coord is color.
// False if out of bounds or not that color.
bool point_is_color(int x, int y, SDL_Color color) const;
private:
SDL_Surface* sdl_impl;
bool is_alpha;
Uint32 alpha_color;
typedef std::map<std::string, GUIImage*> image_map_t;
};
#endif /* GUIIMAGE_H */