From c965e8a1f340675bc8a10638470f818e3f743724 Mon Sep 17 00:00:00 2001 From: Lode Date: Wed, 9 Dec 2015 00:20:41 +0100 Subject: Made load_file function return error if file can't be opened --- examples/example_decode.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'examples/example_decode.cpp') diff --git a/examples/example_decode.cpp b/examples/example_decode.cpp index 4eee6b8..76cda6e 100644 --- a/examples/example_decode.cpp +++ b/examples/example_decode.cpp @@ -58,8 +58,8 @@ void decodeTwoSteps(const char* filename) unsigned width, height; //load and decode - lodepng::load_file(png, filename); - unsigned error = lodepng::decode(image, width, height, png); + unsigned error = lodepng::load_file(png, filename); + if(!error) error = lodepng::decode(image, width, height, png); //if there's an error, display it if(error) std::cout << "decoder error " << error << ": " << lodepng_error_text(error) << std::endl; @@ -76,8 +76,8 @@ void decodeWithState(const char* filename) unsigned width, height; lodepng::State state; //optionally customize this one - lodepng::load_file(png, filename); //load the image file with given filename - unsigned error = lodepng::decode(image, width, height, state, png); + unsigned error = lodepng::load_file(png, filename); //load the image file with given filename + if(!error) error = lodepng::decode(image, width, height, state, png); //if there's an error, display it if(error) std::cout << "decoder error " << error << ": "<< lodepng_error_text(error) << std::endl; -- cgit v1.2.3