From dfda9199a45a2bb4789eb962b03cb596578d8a3d Mon Sep 17 00:00:00 2001 From: Harry Jeffery Date: Mon, 9 Nov 2015 15:27:16 +0000 Subject: Make error logging clearer --- main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index ab07e36..7e7d225 100644 --- a/main.c +++ b/main.c @@ -285,6 +285,12 @@ void load_image(const char* path) } FREE_IMAGE_FORMAT fmt = FreeImage_GetFileType(path,0); + + if(fmt == FIF_UNKNOWN) { + fprintf(stderr, "Could not identify file: '%s'. Ignoring.\n", path); + return; + } + if(fmt == FIF_GIF) { load_gif(path); return; @@ -297,6 +303,10 @@ void load_image(const char* path) g_img.playing = 0; FIBITMAP *image = FreeImage_Load(fmt, path, 0); + if(!image) { + fprintf(stderr, "Error loading file: '%s'. Ignoring.\n", path); + return; + } FIBITMAP *frame = FreeImage_ConvertTo32Bits(image); FreeImage_FlipVertical(frame); render_image(frame); @@ -432,7 +442,6 @@ int main(int argc, char** argv) while(g_path.changed) { load_image(g_path.cur->path); if(g_img.tex == NULL) { - fprintf(stderr, "Ignoring unsupported file: %s\n", g_path.cur->path); remove_current_path(); } else { g_path.changed = 0; -- cgit v1.2.3