which will create the implementation of the libraries (both SDL_stbimage
and stb_image) there. Isn’t that a lot easier than integrating libpng,
libjpeg etc in your buildsystem?
which will create the implementation of the libraries (both SDL_stbimage
and stb_image) there. Isn’t that a lot easier than integrating libpng,
libjpeg etc in your buildsystem?
I guess SaveSurface_RW() is pretty easy with stb_image_write, you only
need to write a wrapper around SDL_RWwrite() for stbi_write_func.
One disadvantage of stb_image_write is that the png compression is kinda
poor, the resulting files are often 40-50% bigger than what you’d get
with libpng and 40% bigger than the results from LodePNG.
But it’s still a lot smaller than TGA (even with RLE), so I guess it’s
bearable.
I dunno if I should add support for writing - I guess if there is demand
for it I’d put it in a separate lib and also use stb_image_write.
But currently I’m curious if anyone actually ends up using
SDL_stbimage.h
Cheers,
DanielOn 11/19/2015 07:49 PM, Jonathan Dearborn wrote:
This looks pretty nice!
I’ll have to look it over and compare it to my implementation in
SDL_gpu, which uses stb-image and stb-image-write.
SDL_gpu has GPU_LoadSurface, GPU_LoadSurface_RW, and GPU_SaveSurface
functions (hmm… looks like it needs SaveSurface_RW).
Yeah, stb_image_write’s PNG compression is also very slow (~800 ms for a
screen-sized image). I have to use TGA when saving images as state in
apps. For me it’d be great if only that were fixed.
Jonny DOn Thu, Nov 19, 2015 at 4:32 PM, Daniel Gibson wrote:
On 11/19/2015 07:49 PM, Jonathan Dearborn wrote:
This looks pretty nice!
I’ll have to look it over and compare it to my implementation in
SDL_gpu, which uses stb-image and stb-image-write.
SDL_gpu has GPU_LoadSurface, GPU_LoadSurface_RW, and GPU_SaveSurface
functions (hmm… looks like it needs SaveSurface_RW).
I only support loading surfaces, no writing.
I guess SaveSurface_RW() is pretty easy with stb_image_write, you only
need to write a wrapper around SDL_RWwrite() for stbi_write_func.
One disadvantage of stb_image_write is that the png compression is kinda
poor, the resulting files are often 40-50% bigger than what you’d get with
libpng and 40% bigger than the results from LodePNG.
But it’s still a lot smaller than TGA (even with RLE), so I guess it’s
bearable.
I dunno if I should add support for writing - I guess if there is demand
for it I’d put it in a separate lib and also use stb_image_write.
But currently I’m curious if anyone actually ends up using SDL_stbimage.h
It also still supports SDL2 and (with limited functionality) SDL1.2.
I think the only thing to keep in mind as a user is that when using SDL3, you either need to #include <SDL3/SDL.h>or#define SDL_STBIMG_SDL3before including it.
Otherwise not much has changed
Instead of SDL_bool now bool (from <stdbool.h>) is used, for all SDL versions
The functions with _RW in their names (like SDL_Load_RW()) have been renamed to have _IO in their names instead (like SDL_Load_IO()) when using SDL3 - but defines for the old names are provided (#define SDL_Load_RW SDL_Load_IO) so the old names still work.
For SDL2 and SDL1.2 the function names have not changed.