cnjinhao / nana

a modern C++ GUI library
https://nana.acemind.cn
Boost Software License 1.0
2.29k stars 331 forks source link

BMP support is unreliable #657

Closed ventsin closed 2 years ago

ventsin commented 2 years ago

I've been testing parts of the library and I consistently failed to load BMPs correctly, be it from memory or from the filesystem.

nana::paint::image img;
if (!img.open(data, size))
    return;
//or
if (!img.open("test.bmp"))
    return;

nana::picture pic;
pic.create(fm);
if (!pic.load(img))
    return;
pic.move(150, 10);
pic.size({ 32, 32 });

Both open and load return true, however the result is always a completely gray image!

On that note, I want to ask @cnjinhao and @qPCR4vir what your thoughts are on using STB Image for loading routines instead of supporting formats directly? It should provide robust reading of images and since it's header-only, it would simplify nana building/installing immensely, since it wouldn't rely on libpng and libjpg directly.

I wouldn't mind working on a PR but I'd like to know your thoughts before working on it.

cnjinhao commented 2 years ago

It’s just a bug on support of a specific BMP format. Would you please send me the bmp file to my email?

ventsin commented 2 years ago

test.zip I don't know your address, so I uploaded the file here. If you need it via email let me know.

cnjinhao commented 2 years ago

Fixed! New fix has been checked into branch develop-1.8.

ventsin commented 2 years ago

Thank you, it works great now!