2


I'm trying to load an image onto a Boost.GIL image from an std::istream. I've searched online but have yet to find a good solution.
Any help would be greatly appreciated.
Thanks alot

combinatorial
  • 9,132
  • 4
  • 40
  • 58
Tal Zion
  • 1,331
  • 2
  • 14
  • 23

1 Answers1

4

Take a look at the new version of gil io from here: http://code.google.com/p/gil-contributions/source/browse/trunk/gil_2.zip This is not officially part of boost yet, but it works well and is stable, and it supports what you need. You don't say what format you are trying to read, but to read jpeg you would have code like this:

using namespace boost::gil;
image_read_settings<jpeg_tag> readSettings;
rgb8_image_t newImage;
read_image(stream, newImage, readSettings);

Reading png, bmp, raw, targa and tiff is also supported.

combinatorial
  • 9,132
  • 4
  • 40
  • 58
  • 2
    +1 It's worth to clarify "not officially part of Boost yet". The new version of Boost.GIL.IO extension has been reviewed and accepte to Boost. It should be included and released in near future. Details at http://lists.boost.org/boost-announce/2011/01/0281.php – mloskot Oct 09 '12 at 09:41
  • 1
    Don't forget to open such streams in binary mode! – timday Oct 15 '12 at 19:15