使用Boost.GIL创建图像 [英] Creating image with Boost.GIL

查看:214
本文介绍了使用Boost.GIL创建图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试阅读boost :: gil文档,但是它介于缺乏和令人困惑之间.

I've been trying to read the boost::gil documentation, but it's somewhere between lacking, and convoluted.

除了搁浅之外,我还需要一个有关如何执行以下操作的示例:

Ranting aside, I need an example on how to do the following:

创建一个图像,例如512x512.用红色像素填充它.写入PNG.

Create an image of, say 512x512. Fill it with red pixels. Write to PNG.

在gil的文档中,我什么都找不到.尤其是创建图像或用像素部分填充图像.

I can't find anything about doing any of that, at all, in the documentation for gil. Particularly the creating an image or filling it with pixels part.

如果有人可以帮助,谢谢.

If anyone can help, thanks.

推荐答案

我还没有使用过GIL,但我也想学习它.查看了设计指南并搜索了与libpng相关的错误,最简单的例子是

I haven't used GIL yet, but I want to learn it as well. Having looked at the design guide and having googled up the error related to libpng, looks like the simplest example is

#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,生成此图像

works for me, with -lpng on command line, producing this image

这篇关于使用Boost.GIL创建图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆