lvandeve / lodepng

PNG encoder and decoder in C and C++.
zlib License
2.06k stars 421 forks source link

Little Endian 16bit output #63

Closed eruffaldi closed 6 years ago

eruffaldi commented 6 years ago

LCT_GREY equivalent but with Little Endian

lvandeve commented 6 years ago

No plans to implement this, LodePNG only outputs to the color types that are defined in the PNG specification (https://www.w3.org/TR/2003/REC-PNG-20031110/) itself, including their endianness.

Reason: there is a huge combinatory explosion of color types (endianness, ordering of RGB, amount of bits of each channel, ...). Supporting this is out of the scope of this PNG loading library.

But the good news it it's relatively easy to switch from one to the other with a single for loop. For example in this case switching the order of every pair of bytes. This can be done after decoding. There is no disadvantage of performance, because if it were done inside of LodePNG it would do the same for loop inside of it.

I hope that works.

eruffaldi commented 6 years ago

I have a patch for this mainly for speeding up the loading into GPU but the statement "if it were done inside of LodePNG it would do the same for loop inside of it." convinced me.

Thanks

-E