We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4249 - [Patch] Add USE_STBIMAGE for LoadPNG/LoadJPG, USE_TINYJPEG for SaveJPG
Summary: [Patch] Add USE_STBIMAGE for LoadPNG/LoadJPG, USE_TINYJPEG for SaveJPG
Status: NEW
Alias: None
Product: SDL_image
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.3
Hardware: All All
: P2 enhancement
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-09-04 17:17 UTC by Ethan Lee
Modified: 2020-01-30 21:59 UTC (History)
0 users

See Also:


Attachments
stb_image/tinyjpeg support patch (314.62 KB, patch)
2018-09-04 17:17 UTC, Ethan Lee
Details | Diff
stb_image/tinyjpeg support patch [v2] (314.67 KB, patch)
2018-10-02 17:15 UTC, Ethan Lee
Details | Diff
stb_image/tinyjpeg support patch [v3] (314.94 KB, patch)
2020-01-30 21:59 UTC, Ethan Lee
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ethan Lee 2018-09-04 17:17:22 UTC
Created attachment 3296 [details]
stb_image/tinyjpeg support patch

Attached is a patch that uses stb_image and tinyjpeg as fallbacks for configurations where libpng/libjpeg is not available. USE_STBIMAGE and USE_TINYJPEG defines are used to guard those portions of the code.

Notably absent from this patch is project file updates, including ./configure options. It shouldn't be _too_ hard to add, just '--enable-stb-image' and '--enable-tinyjpeg' with both defaulting to 'no' should be enough, and it'll only matter if libpng/libjpeg are disabled/missing.

A test repo is available here:

https://github.com/FNA-XNA/SDL_image_compact
Comment 1 Ethan Lee 2018-09-04 17:25:49 UTC
Oh yeah, one more thing: You'll notice that IsPNG and IsJPG are duplicated for the fallback paths - I wasn't sure how to isolate that, but this could definitely be made smaller by taking the existing copies of the function and expose them to other implementations of PNG/JPG support.
Comment 2 Ethan Lee 2018-10-02 17:15:54 UTC
Created attachment 3336 [details]
stb_image/tinyjpeg support patch [v2]

Patch has been updated with some warning fixes for WinRT. Still need to figure out the best way to incorporate this into the projects and merge the IsPNG/IsJPG paths, need feedback on that before this can move forward.
Comment 3 Ethan Lee 2020-01-30 21:59:22 UTC
Created attachment 4183 [details]
stb_image/tinyjpeg support patch [v3]

New version to fix a leak in the stb loader.