#include "image.h" #include #include #include Image::Image(const char * fileName, int flags) : width {}, height {}, numComponents {} { unsigned char * bytes = stbi_load(fileName, &width, &height, &numComponents, flags); if (!bytes) { throw std::runtime_error {std::string {"Unable to load image: "} + fileName}; } data = {bytes, static_cast(width * height * numComponents)}; } Image::~Image() { stbi_image_free(data.data()); }