-
Notifications
You must be signed in to change notification settings - Fork 214
IMG.c: Loader now keeps trying other formats, if other supported format(s) failed to load an image #555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…at(s) failed to load an image
This means that if we fail to load an image the error will always be "Unsupported image format" and we lose any informative error set by the loader. |
The TIFF image format is well defined, I'm not sure why this RIFF/WEBP image would be detected as TIFF. |
I suspect that the image is, maybe, too small, but that's not the bug that SDL could fix. |
We could also move TIFF to the bottom of the list. Did you see this comment?
|
Yep, just thinking if there is a nice way to handle that :) |
Moving TIFF to the bottom would probably fix my issue; However, I'm a little bit worried that it may cause others. What's your opinion on that? Moving TIFF to the bottom is the easiest way, but I could spend some more time & fix the SDL_GetError() issue in my PR. |
Fixing the GetError() issue is probably the best route. |
GetError() issue is now fixed by tracking how many load attempts we've made. |
You actually need to save off the error in the case where an image load was attempted, as the error might be overridden by a subsequent is() call. |
Did not account for that, sry |
Looks good. We need to do the same in IMG_LoadAnimationTyped_IO() |
I'm not 100% comfortable with this patch |
I can see why, it may be too much to fix, possibly, one small edge case We are going to keep the original version of it anyway, cause without it, I'd have to go and manually find all the broken images & convert them to other formats, like PNG. On the other hand, I hate to modify original source code, and since Apple is (almost) definitely not going to do anything about it, I thought that maybe an official fix is possible |
…nstead of a raw pointer
Hi
This PR makes IMG.c keep trying to load an image if another format fails.
The reason I even had this problem comes from trying to load this WebP image on iOS (I could not attach it to PR as GitHub does not support this format)
For some reason, this image was recognized as a TIF format image by the
UTTypeConformsTo
. I tried replacing it with theUTTypeEqual
, but got the same result. The image load was failing because the TIF format check was performed before checking against WEBP.While the problem I had is likely some rare edge case, I believe it would still be a good thing to try to handle such rare hiccups.