我一直在尝试阅读boost::gil文档,但是它介于缺乏和困惑之间。
暂且不谈,我需要一个有关如何执行以下操作的示例:
创建一个图像,例如512x512。用红色像素填充它。写入PNG。
在gil的文档中,我什么都找不到。特别是创建图像或用像素部分填充图像。
如果有人可以帮助,谢谢。
最佳答案
我还没有使用过GIL,但是我也想学习它。看过design guide并用googlet到the error related to libpng之后,看起来最简单的例子是
#define png_infopp_NULL (png_infopp)NULL
#define int_p_NULL (int*)NULL
#include <boost/gil/gil_all.hpp>
#include <boost/gil/extension/io/png_dynamic_io.hpp>
using namespace boost::gil;
int main()
{
rgb8_image_t img(512, 512);
rgb8_pixel_t red(255, 0, 0);
fill_pixels(view(img), red);
png_write_view("redsquare.png", const_view(img));
}
对我有用,在命令行上使用
-lpng
生成this image关于c++ - 使用Boost.GIL创建图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5889235/