Boost logo

Boost Users :

Subject: Re: [Boost-users] [boost-users][GIL] Colors broken after moving to New IO
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2011-03-06 13:35:00


2011/3/6 Christian Henning <chhenning_at_[hidden]>:
> Hi Szymon, the new IO extension isn't yet part of boost. Are you
> referring to my repository at good code?
>
> Also there is no png_load_file() in the old version nor is there a
> load_image() in the new IO. The test code reads and writes png's in
> various formats. What is your format? A little code would be nice,
> too. ;-)
>

Sorry for not checking for valid function names. I used this code:
http://gil-contributions.googlecode.com/files/boost_review.zip. A
little portion of my code then ;)

    using namespace boost::gil;

    typedef boost::mpl::vector<rgb8_image_t, rgba8_image_t> image_types;

    any_image<image_types> image;

    try
    {
      png_read_image(file, image);
      //read_image(file, image, png_tag());

      init();

      if (image.current_type_is<rgb8_image_t>())
      {
        setData(view(image._dynamic_cast<rgb8_image_t>()));
      }
      else if (image.current_type_is<rgba8_image_t>())
      {
        setData(view(image._dynamic_cast<rgba8_image_t>()));
      }
    }
    catch (const std::exception& e)
    {
      throw Exception(e.what()) << ". File: " << file;
    }

this is a snippet from implementation of 2D OpenGL texture. setData()
is overloaded for various image formats so that valid constant is
passed to GL Api (rgb8_image_t image overload passes GL_RGB8 etc). I
didn't do anything but changing png_read_image() to read_image() and
after running app all images on screen were broken - most of images is
white.

On a side note: maybe new io could use boost::exception? Would be
great if read_image() used boost::errinfo_file_name() when file cannot
be opened as now it is not better than just returning error code.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net