| Summary: | support for bit depths other than 32bit in IMG_SavePNG | ||
|---|---|---|---|
| Product: | SDL_image | Reporter: | Jonathan Dowland <jon+bugzilla.libsdl> |
| Component: | misc | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | fabian+debian |
| Version: | 2.0.1 | ||
| Hardware: | All | ||
| OS: | All | ||
| Attachments: | libpng-based implementation of IMG_SavePNG_RW | ||
|
Description
Jonathan Dowland
2016-07-15 14:02:47 UTC
Is there a chance this gets addressed in the future, e.g. by actually using libpng for writing out PNG files instead of the embedded miniz stuff? Sure, would you like to contribute a patch? It's on my TODO list for quite some time now, but will probably havw to wait until after the Chocolate Doom 3.0 release (which will be based on SDL2). Okay, good luck on your release! :) Created attachment 2926 [details] libpng-based implementation of IMG_SavePNG_RW So, I had some free time over the weekend and this is what I have come up with so far. My workign branch can be found here: https://github.com/fabiangreffrath/SDL_Image/tree/IMG_SavePNG_RW_libpng Some remarks: 1) I am not sure if libpng requires to adapt the target color space "png_format" based on system endianess, so I have just kept this code for both implementations. Unfortunately, I don't have access to a big-endian system to test this myself. 2) I'd prefer to get rid of the setjmp()-based error handling voodoo (which I frankly speaking don't understand) and instead add two static functions for error handling, i.e. logging with SDL_LogWarn() and SDL_LogError(), respectively. However, I hesitated to do this yet, because it would be orthogonal to the initial purpose of the patch. 3) This is an early implementation and I am open for suggestions. I have not yet commented or restructured the code, so if you feel that some passages need more tuning, please tell me. - Fabian This is a great first pass. I committed it: https://hg.libsdl.org/SDL_image/rev/4076ac7cf0a1 I'll leave this bug open, feel free to attach additional patches as you iterate and close it when you're done once I've applied your patches. Thanks! *** Bug 3595 has been marked as a duplicate of this bug. *** I have just tested on a Debian porter box (pizzetti which is a ppc64) and can confirm that SDL_PIXELFORMAT_RGBA8888 is the correct pixel format for this system. Fabian, I'm going to close out this bug, but feel free to attach more patches as you refine it. Thanks! Fine, thanks! |