Created Image

This commit is contained in:
Kayne Ruse
2013-04-29 02:50:58 +10:00
parent 1226fa08ca
commit d72a3f4fb5
5 changed files with 78 additions and 11 deletions
+31
View File
@@ -0,0 +1,31 @@
#include "image.h"
Image::Image(SDL_Surface* p) {
SetSurface(p);
}
Image::Image(SDL_Surface* p, SDL_Rect r) {
SetSurface(p, r);
}
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
surface = p;
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
return surface;
}
SDL_Surface* Image::SetSurface(SDL_Surface* p, SDL_Rect r) {
surface = p;
clip = r;
return surface;
}
SDL_Surface* Image::GetSurface() const {
return surface;
}
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
SDL_Rect sclip = clip, dclip = {x,y};
SDL_BlitSurface(surface, &sclip, dest, &dclip);
}