我使用的是png++,运行正常,但您需要将像素类型设置为模板参数:
png::image< png::rgb_pixel > image("input.png");问题是在编译时我不知道它是rgb,rgba等等。似乎找不到一种方法让png++告诉我png中到底有什么信息。
有什么想法吗?
谢谢。
发布于 2011-01-21 01:32:41
尝试使用reader。然后查看它的基类io_base的成员函数。我想它有你要找的东西。
发布于 2011-01-21 15:16:43
嘿,png++的作者在这里提供帮助:)
如果你真的需要知道PNG图像中的像素格式,使用png::reader是受支持的方式:
png::reader< std::istream > reader(my_stream);
reader.read_info();
png::color_type color_type = reader.get_color_type();但是,如果你不关心图像的颜色类型,只是想把它加载到,例如RGBA buffer中,我建议使用png::image< rgba_pixel > image("input.png"):这会自动为你将任何颜色类型的PNG图像转换成RGBA。
https://stackoverflow.com/questions/4750048
复制相似问题