You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is pretty minor, but I think it's worth reporting regardless: with the new STB PNG/JPG back end, reading in a JPEG image results in IMG_GetError() being populated with "Not a PNG" despite the image loading successfully (even with IMG_LoadJPEG_RW).
Not sure if it's a quirk with how stb_image identifies file formats or not, but a one-line fix would presumably be to just always call IMG_ClearError right before an image is successfully returned to avoid any confusion (e.g. encountering a different problem later that doesn't set an error, and getting a head-scratching "Not a PNG" when checking GetError for information). Would that approach work, or are there legitimate cases where you'd want an error set while still returning a valid image surface?
Thanks in advance!
The text was updated successfully, but these errors were encountered:
I'm fine with adding that, but in general SDL functions may set errors even if they eventually return successfully. The application shouldn't check the error message to determine if a function succeeds or fails, only to find more detail if a function returns failure.
That makes sense (and is usually how I write things), the only time I check for error text before return value is in various PySDL2 unit tests just to make sure I get any error message before asserting a return value (how I caught this), and it's easy enough to ignore non-fatal errors in that context when I hit them.
I'm mostly reporting this because this specific error text is misleading and confusing; I spent a while trying to figure out whether I'd accidentally saved my JPEG with a .png extension before looking at the source and realizing it was an internal STB message.
This is pretty minor, but I think it's worth reporting regardless: with the new STB PNG/JPG back end, reading in a JPEG image results in
IMG_GetError()
being populated with"Not a PNG"
despite the image loading successfully (even withIMG_LoadJPEG_RW
).Not sure if it's a quirk with how
stb_image
identifies file formats or not, but a one-line fix would presumably be to just always callIMG_ClearError
right before an image is successfully returned to avoid any confusion (e.g. encountering a different problem later that doesn't set an error, and getting a head-scratching"Not a PNG"
when checking GetError for information). Would that approach work, or are there legitimate cases where you'd want an error set while still returning a valid image surface?Thanks in advance!
The text was updated successfully, but these errors were encountered: