3 #include <SDL_image/SDL_image.h>
11 Image::Image(const string
& path
) :
17 surface_
= IMG_Load(path
.c_str());
19 SDL_Surface
*optimized
= SDL_DisplayFormat(surface_
);
20 SDL_FreeSurface(surface_
);
26 clipMask_
.w
= width();
27 clipMask_
.h
= height();
32 SDL_FreeSurface(surface_
);
36 int Image::width() const {
40 int Image::height() const {
44 const std::pair
<int32_t, int32_t> Image::position() const {
48 void Image::setPosition(const std::pair
<int32_t, int32_t>& position
) {
52 void Image::draw(SDL_Surface
*dest
) const
54 SDL_Rect dstrect
= { position_
.first
, position_
.second
, 0, 0 };
55 SDL_BlitSurface(surface_
, const_cast<SDL_Rect
*>(&clipMask_
),