From 39a045314cb310bc71766e91b34817df5384094c Mon Sep 17 00:00:00 2001 From: cflip Date: Sat, 29 Jan 2022 22:29:06 -0700 Subject: Close program on image read failure --- src/bitmap.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bitmap.cpp b/src/bitmap.cpp index 612f2af..a85cceb 100644 --- a/src/bitmap.cpp +++ b/src/bitmap.cpp @@ -3,13 +3,16 @@ #define STB_IMAGE_IMPLEMENTATION #include +#include + Bitmap::Bitmap(const char* image) { int width, height, bitDepth; uint8_t* buffer = stbi_load(image, &width, &height, &bitDepth, STBI_rgb_alpha); if (!buffer) { - return; + std::cerr << "Failed to read image from " << image << std::endl; + exit(1); } this->width = width; -- cgit v1.2.3