lodepng could supply a helper for bit-depth from PNG header.
alecazam opened this issue · 2 comments
I noticed that stbi_image and lodepng don't provide any helper calls that I saw to determine whether incoming png data is 8- or 16-bit from parsing the png header. What ends up happening is callers then to rely on the default argument (8-bit), or pass 8-bit, and then loaders can't load 16-bit data.
Since lodepng is already typically reading the png from memory, this traversal is fairly simple. I think this would help callers pick the right load type. 8 for images, and 16-bit for heightmaps for example.
This is just the bitdepth field of the IHDR block which must occur first in the block stream of the PNG. 1/2/4/8/16 are all possibilities.
Hi, it's actually possible with lodepng_inspect: that function only looks at the start of the file and dumps the information in the state object
Does that work?
Ah, that's what I needed. Thanks.