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

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. :frowning:
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!

MasonFrom: 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.

./lxnt


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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.
:frowning:
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 :slight_smile: Or maybe my cat is,
given the number of silly bugs lately.
But no worries :).

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.On Sun, Jan 31, 2016 at 12:56 AM, Mason Wheeler wrote:

./lxnt

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

Cheers,
DanielOn 01/30/2016 01:23 AM, Alexander Sabourenkov wrote:

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.

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 :slight_smile:
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.On Sun, Jan 31, 2016 at 7:09 AM, Daniel Gibson wrote:

On 01/30/2016 01:23 AM, Alexander Sabourenkov wrote:

./lxnt

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. :frowning:

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.

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…
MasonFrom: mr_tawan <mr_tawan at hotmail.com>
To: sdl at lists.libsdl.org
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
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

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

In other news, with great help from Mason SDL_pnglite now builds just fine on windows. Many thanks to him.From: Alexander Sabourenkov
Subject: Re: [SDL] SDL_pnglite - a lightweight PNG reader/writer

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

My pleasure.On Wed, Feb 3, 2016 at 6:49 PM, Mason Wheeler wrote:

./lxnt