开发者

Boost GIL image constructors

开发者 https://www.devze.com 2023-01-17 06:16 出处:网络
I\'m currently trying to figure out how to use the Generic Image Library included in Boost. Right now, I just want to use the library to store pixel data and use the Image IO to write PNGs. I\'m havin

I'm currently trying to figure out how to use the Generic Image Library included in Boost. Right now, I just want to use the library to store pixel data and use the Image IO to write PNGs. I'm having trouble understanding just how to set up the object however.

The hpp says

image(const point_t& dimensions,
      std::size_t alignment=1) : _memory(0), _align(alignment) {
    allocate_and_default_construct(dimensions);
}

but I cannot find any references to point_t except a type_def for view_t::point_t to point_t.

Also, the tutoria开发者_StackOverflow中文版l found with the GIL seems to only include writing filters and generic algorithms, and thus each function example they provide has a source image view, from which they take the dimensions.

Am I going about this the wrong way? Or is there something I've missed completely?

Thanks in advance

Edit: I don't know if anyone cares, or has read this, but for the record, I just used the boost interleaved image function to create a PNG. It's not exactly the same solution, but it works for my applications.


it sounds like you solved your problem in the meantime, but just for the record... here are some pointers to information about your problem:

  1. First of all you may have missed the second constructor of boost::gil::image, which offers explicit access to the horizontal and vertical dimensions without the need of the point_t:

    image(x_coord_t width, y_coord_t height,
        std::size_t alignment=0,
        const Alloc alloc_in = Alloc()) : _memory(0), _align_in_bytes(alignment), _alloc(alloc_in) {
        allocate_and_default_construct(point_t(width,height));
    }
    
  2. point_t will most likely refer to the point2 class template defined in boost/gil/utilities.hpp.

  3. In general you should check the complete documentation of Boost GIL for all questions not mentioned in the tutorial. For a deeper understanding of the library it is absolutely necessary to get familiar with the Design Guide and the Doxygen Documentation.

0

精彩评论

暂无评论...
验证码 换一张
取 消