mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-10 06:34:01 +00:00
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.
This commit is contained in:
parent
41b5d8eb4e
commit
3d88d7eefc
1 changed files with 5 additions and 1 deletions
|
@ -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<float>(width);
|
||||
h = static_cast<float>(height);
|
||||
|
@ -127,6 +130,7 @@ bool JpgLoader::read()
|
|||
|
||||
//decompress jpg image
|
||||
if (tjDecompress2(jpegDecompressor, data, size, image, static_cast<int>(w), 0, static_cast<int>(h), TJPF_BGRX, 0) < 0) {
|
||||
TVGERR("JPG LOADER", "%s", tjGetErrorStr());
|
||||
tjFree(image);
|
||||
image = nullptr;
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue