Imported updates from Codebase
This commit is contained in:
+13
-1
@@ -21,6 +21,10 @@
|
||||
*/
|
||||
#include "image.hpp"
|
||||
|
||||
Image::Image() {
|
||||
SetSurface(nullptr);
|
||||
}
|
||||
|
||||
Image::Image(SDL_Surface* p) {
|
||||
SetSurface(p);
|
||||
}
|
||||
@@ -31,7 +35,12 @@ Image::Image(SDL_Surface* p, SDL_Rect r) {
|
||||
|
||||
SDL_Surface* Image::SetSurface(SDL_Surface* p) {
|
||||
surface = p;
|
||||
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
|
||||
if (!surface) {
|
||||
clip = {0, 0, 0, 0};
|
||||
}
|
||||
else {
|
||||
clip = {0, 0, (Uint16)surface->w, (Uint16)surface->h};
|
||||
}
|
||||
return surface;
|
||||
}
|
||||
|
||||
@@ -46,6 +55,9 @@ SDL_Surface* Image::GetSurface() const {
|
||||
}
|
||||
|
||||
void Image::DrawTo(SDL_Surface* dest, Sint16 x, Sint16 y) {
|
||||
if (!surface) {
|
||||
return;
|
||||
}
|
||||
SDL_Rect sclip = clip, dclip = {x,y};
|
||||
|
||||
SDL_BlitSurface(surface, &sclip, dest, &dclip);
|
||||
|
||||
Reference in New Issue
Block a user