Using Boost.GIL to convert an image into “raw” bytes

后端 未结 4 1607
星月不相逢
星月不相逢 2021-01-06 09:53

Goal

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

4条回答
  •  轮回少年
    2021-01-06 10:22

    Here's some code I once used:

     unsigned char * buf = new unsigned char[w * h];
    
     boost::gil::gray8_view_t image =
              boost::gil::interleaved_view(w, h, (boost::gil::gray8_pixel_t*)buf, w);
    
     for (size_t i = 0; i < ...; ++i)
     {
       boost::gil::gray8_view_t::x_iterator it = image.row_begin(i);
    
       // use it[j] to access pixel[i][j]
     }
    

    It's only for grayscale, but presumably the coloured version is similar.

提交回复
热议问题