Reading png images with gil

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

With the following, I have to know the type in advance, and this is not so neat.

 boost::gil::rgb8_image_t im; gil::png_read_image(m_filename, im); 
+4
source share
2 answers

You can create a list of the types you want to try and use any_image to store the erase 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); 

A source

+3
source

An alternative to presenting runtime information any_image uses the _ _read_and_convert_image family of functions (png_read_and_convert_image for your case)

+3
source

Source: https://habr.com/ru/post/1382027/


All Articles