You could also simply create a view on your memory buffer (using boost::gil::interleaved_view) and then copy the pixels of your source view to this new view.

This would give something like (untested, uncompiled, pseudocode) :

data = (unsigned char*)malloc(src_view.width()*src_view.height()*4);
dst_view = boost::gil::interleaved_view(src_view.width(), src_view.height(), data, src_view.width()*4);
std::copy(src_view.begin(), src_view.end(), dst_view.begin());

and you're done...