diff --git a/src/RageSurface.cpp b/src/RageSurface.cpp index 02170983a6..938778ec8d 100644 --- a/src/RageSurface.cpp +++ b/src/RageSurface.cpp @@ -1,7 +1,7 @@ -#include "global.h" +#include "global.h" #include "RageSurface.h" #include "RageUtil.h" - +#include "../../extern/stb-master/stb_image.h" #include int32_t @@ -135,8 +135,9 @@ RageSurfaceFormat::Equivalent(const RageSurfaceFormat& rhs) const RageSurface::RageSurface() { - pixels = NULL; + pixels = nullptr; pixels_owned = true; + stb_loadpoint = false; } RageSurface::RageSurface(const RageSurface& cpy) @@ -153,10 +154,11 @@ RageSurface::RageSurface(const RageSurface& cpy) pixels = NULL; } -RageSurface::~RageSurface() -{ - if (pixels_owned) - delete[] pixels; +RageSurface::~RageSurface(){ + + if (pixels_owned) delete[] pixels; + if (stb_loadpoint) + stbi_image_free(pixels); } static int diff --git a/src/RageSurface.h b/src/RageSurface.h index b5a6a4e6e9..6155332e93 100644 --- a/src/RageSurface.h +++ b/src/RageSurface.h @@ -1,4 +1,4 @@ -/* RageSurface - holds a simple 2d graphic surface */ +/* RageSurface - holds a simple 2d graphic surface */ #ifndef RAGE_SURFACE_H #define RAGE_SURFACE_H @@ -84,9 +84,9 @@ struct RageSurfaceFormat struct RageSurface { RageSurfaceFormat fmt; - uint8_t* pixels; bool pixels_owned; + bool stb_loadpoint; int32_t w, h, pitch; int32_t flags;