Reading png images with gil

有些话、适合烂在心里 提交于 2019-12-23 12:47:50

问题


Is it possible with boost::gil to read the RGB image information so that I can read the file into the correct rgbx_image_t?

With the following I have to know the type beforehand and that is not so neat.

boost::gil::rgb8_image_t im;
gil::png_read_image(m_filename, im);

回答1:


You can make a list of types you want to try and use an any_image to hold a type-erased result:

typedef mpl::vector<rgb8_image_t, rgb16_image_t> my_img_types;
any_image<my_img_types> runtime_image;
png_read_image("input.png", runtime_image);

Source




回答2:


Alternative to the introducing any_image runtime stuff is using *_read_and_convert_image functions family (png_read_and_convert_image for your case)



来源:https://stackoverflow.com/questions/8193390/reading-png-images-with-gil

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!