Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Inspecting any_image
From: Szymon Gatner (szymon.gatner_at_[hidden])
Date: 2010-12-28 06:48:46


2010/12/27 Christian Henning <chhenning_at_[hidden]>:
> Hi Szymon,
>
> On Sun, Dec 26, 2010 at 8:39 PM, Szymon Gatner <szymon.gatner_at_[hidden]> wrote:
>> Is it possible to find out which of allowed image formats any_image
>> actually has?
>>
>> For example, if image is loaded with code provided in dynamic_image.cpp:
>>
>>    typedef boost::mpl::vector<gray8_image_t, rgb8_image_t,
>> gray16_image_t, rgb16_image_t> my_images_t;
>>
>>    any_image<my_images_t> dynamic_img;
>>    jpeg_read_image("test.jpg",dynamic_img);
>>
>> how to figure out which colorspace / layout loaded image have?
>>
>
> An any_image is derived from gil::variant which lets you get the index
> from the type vector you specified. There also is a member called
> "current_type_is()". But normally you don't need to cast an any_image
> to a specific type since it should behave like a normal image or view.
>
> Let me know if you have more questions.
>

Thank you very much. I will dig more into this now.

I don't need algorithms now as much as loading and getting format info
as I am using GIL for loading png data and creating OpenGL textures from it.

Until now I was doing it like so:

  try
  {
    rgba8_image_t img;

    png_read_image(file, img);

    setData(view(img));
  }
  catch(...)
  {

  }

  try
  {
    rgb8_image_t img;

    png_read_image(file, img);

    setData(view(img));
  }

with setData() overloaded for different view types / formats. Those
overloads pass
appropriate OpenGL enum representing data layout when texture data is uploaded.

Thanks again.

You are author of new GIL IO, right? I am really looking forward for
it do be included
into BOOST but as I just started using GIL I didn't really feel
competent enough to
participate in the review.

Regards
Szymon Gatner


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