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

Summary: [Patch] Add USE_STBIMAGE for LoadPNG/LoadJPG, USE_TINYJPEG for SaveJPG
Product: SDL_image Reporter: Ethan Lee <flibitijibibo>
Component: miscAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: enhancement    
Priority: P2    
Version: 2.0.3   
Hardware: All   
OS: All   
Attachments: stb_image/tinyjpeg support patch
stb_image/tinyjpeg support patch [v2]
stb_image/tinyjpeg support patch [v3]

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.