C++ 用gil读取png图像

C++ 用gil读取png图像,c++,boost,boost-gil,C++,Boost,Boost Gil,是否可以使用boost::gil读取RGB图像信息,以便将文件读入正确的rgbx\u图像\u t 有了下面的内容,我必须事先知道类型,这并不是很整洁 boost::gil::rgb8_image_t im; gil::png_read_image(m_filename, im); 您可以列出要尝试的类型,并使用any_图像保存类型擦除结果: typedef mpl::vector<rgb8_image_t, rgb16_image_t> my_img_types; any_imag

是否可以使用
boost::gil
读取RGB图像信息,以便将文件读入正确的
rgbx\u图像\u t

有了下面的内容,我必须事先知道类型,这并不是很整洁

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

您可以列出要尝试的类型,并使用
any_图像
保存类型擦除结果:

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);
typedefmpl::vector my\u img\u类型;
任何_映像运行时_映像;
png_read_image(“input.png”,runtime_image);

除了引入任何图像运行时功能外,还可以使用*\u read\u和\u convert\u图像函数系列(png\u read\u和\u convert\u图像适用于您的情况)