The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_pnglite - a lightweight PNG reader/writer
Alexander Sabourenkov
Guest

Hi.


In an unexpected bout of inspiration I sat and patched it up to:


 a) differ as less as possible from SDL2_image's IMG_LoadPNG_RW() in results


 b) preserve as much as possible information when writing out a surface


SDL_pnglite is a small library based on libpnglite to read and write PNG files to/from SDL_Surfaces. The only dependency is zlib. It also is very suitable for static linking.




Testing the loader over PngSuite set shows results identical (as in resulting surfaces)  to IMG_Load() modulo lacking support for 16bit depth and interlacing. A single discrepancy is due to a bug in SDL2_image.

The save path, on the other hand, writes out paletted surfaces as such and preserves colorkey transparency in all cases.



Tests were done on x86_64 and an emulated arm1176, so I'm reasonably sure there are no obvious endianness-related bugs.


https://github.com/lxnt/SDL_pnglite


--


./lxnt
SDL_pnglite - a lightweight PNG reader/writer
Mason Wheeler
Guest

It looks very interesting, but I can't actually use it as-is. There's no VS project file, and when I use cmake to try to generate one, it gives me errors about how it's missing something called "pkg-config", and when I search for that, everything I can see says it's one big long dependency-hell nightmare to try to get that installed on Windows, mainly because whoever maintains it apparently is a *NIX guy who does not know what an installer is. Sad


Since you seem to have it working already, can you either add a project file to the repo or post a compiled Win32 DLL in the project's Releases? Thanks!


Mason



From: Alexander Sabourenkov
To: SDL Development List
Sent: Friday, January 29, 2016 7:23 PM
Subject: [SDL] SDL_pnglite - a lightweight PNG reader/writer


Hi.


In an unexpected bout of inspiration I sat and patched it up to:


a) differ as less as possible from SDL2_image's IMG_LoadPNG_RW() in results


b) preserve as much as possible information when writing out a surface


SDL_pnglite is a small library based on libpnglite to read and write PNG files to/from SDL_Surfaces. The only dependency is zlib. It also is very suitable for static linking.




Testing the loader over PngSuite set shows results identical (as in resulting surfaces) to IMG_Load() modulo lacking support for 16bit depth and interlacing. A single discrepancy is due to a bug in SDL2_image.

The save path, on the other hand, writes out paletted surfaces as such and preserves colorkey transparency in all cases.



Tests were done on x86_64 and an emulated arm1176, so I'm reasonably sure there are no obvious endianness-related bugs.


https://github.com/lxnt/SDL_pnglite


--


./lxnt












_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_pnglite - a lightweight PNG reader/writer
Alexander Sabourenkov
Guest

On Sun, Jan 31, 2016 at 12:56 AM, Mason Wheeler wrote:
Quote:
It looks very interesting, but I can't actually use it as-is.  There's no VS project file, and when I use cmake to try to generate one, it gives me errors about how it's missing something called "pkg-config", and when I search for that, everything I can see says it's one big long dependency-hell nightmare to try to get that installed on Windows, mainly because whoever maintains it apparently is a *NIX guy who does not know what an installer is. Sad


Since you seem to have it working already, can you either add a project file to the repo or post a compiled Win32 DLL in the project's Releases?  Thanks!

Mason








The funny part is that I am its author/maintaner Smile Or maybe my cat is, given the number of silly bugs lately.
But no worries Smile.


Lack of an installer reflects one of the design goals - being lightweight and embeddable, thus the BSD license.
The included build support doesn't even build shared libraries, it is meant to link statically.


Just add the source files to your project, the only dependencies are zlib and SDL2.

If you prefer to build a (static, .LIB) library using cmake, i think I fixed up CMakeLists.txt for that, but I have no way to test this right now.


Please fetch a fresh version from github, I fixed another bug (hope it was the last) in the paletted save path.



--


./lxnt
SDL_pnglite - a lightweight PNG reader/writer
Daniel Gibson
Guest

On 01/30/2016 01:23 AM, Alexander Sabourenkov wrote:
Quote:
SDL_pnglite is a small library based on libpnglite to read and write PNG
files to/from SDL_Surfaces. The only dependency is zlib. It also is very
suitable for static linking.

Sounds neat :-)
Suggestion: You could replace zlib with miniz.c (or parts of it) to
become completely self-contained:
https://code.google.com/archive/p/miniz/
https://github.com/richgel999/miniz

Cheers,
Daniel

_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_pnglite - a lightweight PNG reader/writer
Alexander Sabourenkov
Guest

On Sun, Jan 31, 2016 at 7:09 AM, Daniel Gibson wrote:
Quote:
On 01/30/2016 01:23 AM, Alexander Sabourenkov wrote:
Quote:
SDL_pnglite is a small library based on libpnglite to read and write PNG
files to/from SDL_Surfaces. The only dependency is zlib. It also is very
suitable for static linking.

Sounds neat :-)
Suggestion: You could replace zlib with miniz.c (or parts of it) to become completely self-contained:
https://code.google.com/archive/p/miniz/
https://github.com/richgel999/miniz



Thank you for the suggestion.


I won't do this though. What is gained is unclear - zlib isn't hard to build or link, isn't bloated, is trivial to upgrade and is quite thoroughly tested. Miniz and friends on the other hand don't have the visibility or maintenance devpower and require extensive code modifications to intergrate or update. I also despise the current trend of #include-ing implementation code left and right. It kills maintanability.


In other news, with great help from Mason SDL_pnglite now builds just fine on windows. Many thanks to him.



--


./lxnt
Re: SDL_pnglite - a lightweight PNG reader/writer
mr_tawan


Joined: 13 Jan 2014
Posts: 161
Mason Wheeler wrote:
It looks very interesting, but I can't actually use it as-is. There's no VS project file, and when I use cmake to try to generate one, it gives me errors about how it's missing something called "pkg-config", and when I search for that, everything I can see says it's one big long dependency-hell nightmare to try to get that installed on Windows, mainly because whoever maintains it apparently is a *NIX guy who does not know what an installer is. Sad


The easiest way to get pkg-config runing on Windows is to install "MSYS2". BTW, the purpose of pkg-config is to get the compiler flags, linker flags, and anything required by the GCC toolchains (compiler, linker etc.) to build code using installed library. While CMAKE supports pkg-config I don't think it would work well with Visual Studio.
SDL_pnglite - a lightweight PNG reader/writer
Mason Wheeler
Guest

Yeah, that's exactly my point. I say "this program doesn't have an installer" and the response is "download a specific fork of the CYGWIN command-line and use some magic command-line incantation (which I will not actually provide in this response) to set up pkg-config." If you seriously don't see the problem with that, I really don't know what to say...


Mason





From: mr_tawan
To:
Sent: Wednesday, February 3, 2016 7:25 AM
Subject: Re: [SDL] SDL_pnglite - a lightweight PNG reader/writer




Mason Wheeler wrote: It looks very interesting, but I can't actually use it as-is. There's no VS project file, and when I use cmake to try to generate one, it gives me errors about how it's missing something called "pkg-config", and when I search for that, everything I can see says it's one big long dependency-hell nightmare to try to get that installed on Windows, mainly because whoever maintains it apparently is a *NIX guy who does not know what an installer is.



The easiest way to get pkg-config runing on Windows is to install "MSYS2". BTW, the purpose of pkg-config is to get the compiler flags, linker flags, and anything required by the GCC toolchains (compiler, linker etc.) to build code using installed library. While CMAKE supports pkg-config I don't think it would work well with Visual Studio.



_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
SDL_pnglite - a lightweight PNG reader/writer
Mason Wheeler
Guest

And thanks to you for being willing to work with me on getting it working! Suddenly my graphics conversions look right! Very Happy



From: Alexander Sabourenkov
Subject: Re: [SDL] SDL_pnglite - a lightweight PNG reader/writer


In other news, with great help from Mason SDL_pnglite now builds just fine on windows. Many thanks to him.
SDL_pnglite - a lightweight PNG reader/writer
Alexander Sabourenkov
Guest

On Wed, Feb 3, 2016 at 6:49 PM, Mason Wheeler wrote:
Quote:
And thanks to you for being willing to work with me on getting it working!  Suddenly my graphics conversions look right! Very Happy





My pleasure.



--


./lxnt