Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/CSurface.h
blob: 24418c979391db6ce9c99369ba0a6da6daccec78 (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
//--------------------------------------------------------------------------------------------------
// CSurface.
// A class to represent an image.
//--------------------------------------------------------------------------------------------------

#ifndef __CSURFACE_H__
#define __CSURFACE_H__

#include <SDL.h>
#include <SDL_image.h>

class CSurface
{
	public:
		CSurface(void);
		CSurface(int aWidth, int aHeight);
		CSurface(const char *aFile);
		CSurface(SDL_Surface *aSDLSurface);
		CSurface(SDL_Surface *aSDLSurface, int aFlipFlags);
		~CSurface(void);
		void destroy(void);
		
		static SDL_Surface *loadImage(const char *aFile);
		static void drawImage(SDL_Surface *aImgDst, SDL_Surface *aImgSrc, int aX, int aY);
		static void drawImage(SDL_Surface *aImgDst, SDL_Surface *aImgSrc, int aXDest, int aYDest, int aXSrc, int aYSrc, int aWSrc, int aHSrc);
		static void drawImage(CSurface *aImgDst, CSurface *aImgSrc, int aX, int aY);
		static void drawImage(CSurface *aImgDst, CSurface *aImgSrc, int aXDest, int aYDest, int aXSrc, int aYSrc, int aWSrc, int aHSrc);
		static void drawRect(SDL_Surface *aImgDst, int aX, int aY, int aW, int aH, int aColor);
		static void drawRect(CSurface *aImgDst, int aX, int aY, int aW, int aH, int aColor);

		SDL_Surface *getImage(void);
		void draw(SDL_Surface *aImgDst, int aX, int aY);

		static const int FLIP_HORIZONTAL = 1;
		static const int FLIP_VERTICAL = 2;

	private:
		SDL_Surface *flipSurface(SDL_Surface *surface, int flags);
		void put_pixel32(SDL_Surface *surface, int x, int y, Uint32 pixel);
		Uint32 get_pixel32(SDL_Surface *surface, int x, int y);

		// Image surface.
		SDL_Surface *mImage;
};

#endif /* __CSURFACE_H__ */