From 4877bbaf4e0888ed60f160e3a708ec2cbd40d9ba Mon Sep 17 00:00:00 2001 From: Michal Maciola <71131832+mmaciola@users.noreply.github.com> Date: Sat, 7 Aug 2021 05:00:04 +0200 Subject: [PATCH] JPG loader: print error string on failure Added error string printing on jpg image loading failure. The error message help developer find the corrupted jpg file. Error message is not printed for open from char* data as there the loaders are tried on by one. --- src/loaders/jpg/tvgJpgLoader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/loaders/jpg/tvgJpgLoader.cpp b/src/loaders/jpg/tvgJpgLoader.cpp index f08e063..f3327fb 100644 --- a/src/loaders/jpg/tvgJpgLoader.cpp +++ b/src/loaders/jpg/tvgJpgLoader.cpp @@ -77,7 +77,10 @@ bool JpgLoader::open(const string& path) if (fread(data, size, 1, jpegFile) < 1) goto failure; int width, height, subSample, colorSpace; - if (tjDecompressHeader3(jpegDecompressor, data, size, &width, &height, &subSample, &colorSpace) < 0) goto failure; + if (tjDecompressHeader3(jpegDecompressor, data, size, &width, &height, &subSample, &colorSpace) < 0) { + TVGERR("JPG LOADER", "%s", tjGetErrorStr()); + goto failure; + } w = static_cast(width); h = static_cast(height); @@ -127,6 +130,7 @@ bool JpgLoader::read() //decompress jpg image if (tjDecompress2(jpegDecompressor, data, size, image, static_cast(w), 0, static_cast(h), TJPF_BGRX, 0) < 0) { + TVGERR("JPG LOADER", "%s", tjGetErrorStr()); tjFree(image); image = nullptr; return false; -- 2.7.4