Creating image with Boost.GIL

前端 未结 1 886
南笙
南笙 2020-12-10 12:28

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 follow

相关标签:
1条回答
  • 2020-12-10 13:02

    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));
    }
    

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

    0 讨论(0)
提交回复
热议问题