I\'m trying to move towards Boost GIL to replace some similar functionality I\'ve implemented that is reaching the end of its maintainable life.
I have
I would just push_back each color of the rgb8_pixel_t individually:
struct PixelInserter{
std::vector* storage;
PixelInserter(std::vector* s) : storage(s) {}
void operator()(boost::gil::rgb8_pixel_t p) const {
storage->push_back(boost::gil::at_c<0>(p));
storage->push_back(boost::gil::at_c<1>(p));
storage->push_back(boost::gil::at_c<2>(p));
}
};
int main() {
std::vector storage;
{
using namespace boost::gil;
rgb8_image_t img;
png_read_image("test.png", img);
storage.reserve(img.width() * img.height() * num_channels());
for_each_pixel(const_view(img), PixelInserter(&storage));
}
...
}
...but I'm not an expert on GIL either.