
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

Hi Szymon,
On Sun, Dec 26, 2010 at 8:39 PM, Szymon Gatner
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
my_images_t; any_image
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. Regards, Christian

2010/12/27 Christian Henning
Hi Szymon,
On Sun, Dec 26, 2010 at 8:39 PM, Szymon Gatner
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
my_images_t; any_image
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

Hi Szymon,
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.
Here is a small code example using current_type_is(). http://pastebin.com/TskYcptD It's a bit like dynamic casting. Hope that will help you.
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.
Yes, I'm. Please, everyone is welcome writing a review. Regards, Christian
participants (2)
-
Christian Henning
-
Szymon Gatner