From 84a196ab1ac399c66093598d6724c69096a9a20d Mon Sep 17 00:00:00 2001 From: Bob Polis Date: Sat, 24 Oct 2020 18:01:44 +0200 Subject: [PATCH] added constructor for external surfaces --- Image.cpp | 4 ++++ Image.hpp | 1 + 2 files changed, 5 insertions(+) diff --git a/Image.cpp b/Image.cpp index 604636f..afe30a6 100644 --- a/Image.cpp +++ b/Image.cpp @@ -35,3 +35,7 @@ Image::Image(const std::string& path) { if (!loaded) throw std::runtime_error(IMG_GetError()); _s.reset(loaded); } + +Image::Image(SDL_Surface* surface) { + _s.reset(surface); +} diff --git a/Image.hpp b/Image.hpp index debad3b..43204f9 100644 --- a/Image.hpp +++ b/Image.hpp @@ -19,6 +19,7 @@ namespace sc { public: Image(int w, int h); Image(const std::string& path); + Image(SDL_Surface* surface); SDL_Surface* surface() const { return _s.get(); } int width() const { return _s.get()->w; }