4

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);
manlio
  • 18,345
  • 14
  • 76
  • 126
Buzzzz
  • 887
  • 3
  • 11
  • 18

2 Answers2

3

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

Flexo
  • 87,323
  • 22
  • 191
  • 272
3

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

cybevnm
  • 2,586
  • 4
  • 30
  • 33