#pragma once #include #include namespace Framework { class Image { public: Image(int x, int y, int w, int h, const std::string& File, int Padding = 12) : Destination{ x + Padding/2, y + Padding/2, w - Padding, h - Padding } { ImageSurface = IMG_Load(File.c_str()); #ifdef SHOW_DEBUG_HELPERS Utils::CheckSDLError("Image::Image::IMG_Load"); #endif } void Render(SDL_Surface* Surface) { SDL_BlitScaled(ImageSurface, nullptr, Surface, &Destination); } ~Image() { ReleaseImageSurface(); } Image(const Image&){} /* TODO: THIS IS INCOMPLETE */ Image& operator=(const Image& other) { if (this != &other) { ReleaseImageSurface(); } return *this; } private: SDL_Surface* ImageSurface{ nullptr }; SDL_Rect Destination{ 0, 0, 0, 0 }; void ReleaseImageSurface() { if (ImageSurface) { SDL_FreeSurface(ImageSurface); ImageSurface = nullptr; } } }; }