Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Adding base_channel_type metafunction
From: Christian Henning (chhenning_at_[hidden])
Date: 2010-11-02 11:38:53


Hi Nate, good to hear from you!

Two things:

1. What version of boost are you using? There have some changes in the
current trunk and release branch which should appear in boost 1.45.

2. Could you send me a small test code that exhibits your problem?

Regards,
Christian

On Tue, Nov 2, 2010 at 2:31 AM, Nathan Crookston
<nathan.crookston_at_[hidden]> wrote:
> All,
>
> Several months ago I submitted a patch to prevent warnings when
> performing certain channel conversions [1].  After some discussion
> with Christian a part of the patch was removed in favor of using the
> unsigned_integral_max_value metafunction.  After tweaking my
> specializations of that metafunction my code compiled fine.
>
> Recently I modified my code to use GIL more extensively.  I'm pleased
> with the reduced code footprint (a 5000 line file was reduced to ~150
> lines), but unfortunately there are more warnings due to unsafe
> conversions with my now-more-extensive testing.
>
> Attached is a file which adds a base_channel_type metafunction which
> correctly determines the type which the channel constructor is
> expecting.  I believe this is more correct than using
> unsigned_integral_max_value as the value_type of *max_value is not the
> same as the channel type for, e.g., 8-bit unsigned channels.
> Something like this metafunction has also been requested recently [2].
>
> The following demonstrates its use for the built-in channel type
> models I'm aware of:
> ///////////BEGIN CODE////////////////////
> #include <boost/cstdint.hpp>
> #include <boost/gil/gil_all.hpp>
> #include <boost/static_assert.hpp>
> #include <boost/type_traits/is_same.hpp>
>
> namespace gil = boost::gil;
>
> typedef gil::packed_image3_type<boost::uint16_t, 7,7,2,
> gil::bgr_layout_t>::type bgr772_image_t;
>
> typedef gil::kth_element_type<bgr772_image_t::value_type,0>::type
> b7_element_type;
>
> typedef gil::base_channel_type<b7_element_type>::type b7_type;
>
> BOOST_STATIC_ASSERT((boost::is_same<b7_type, boost::uint8_t>::value));
>
> typedef gil::base_channel_type<gil::channel_type<gil::gray32f_pixel_t>::type>::type
> gray32f_type;
>
> BOOST_STATIC_ASSERT((boost::is_same<gray32f_type, float>::value));
> typedef gil::base_channel_type<gil::channel_type<gil::rgb8_pixel_t>::type>::type
> rgb8_type;
> BOOST_STATIC_ASSERT((boost::is_same<rgb8_type, boost::uint8_t>::value));
>
> int main()
> {}
> /////////END CODE/////////////////
>
> Adding the metafunction and using it to cast values prior to channel
> construction has removed the warnings from my testing.  The diff file
> also contains changes to channel_algorithm.hpp to suppress warnings
> using the supplied metafunction.
>
> I'd be happy to write additional test cases, trac tickets, etc.  The
> changes have been tested with g++3.4, g++4.3 and VC8 (VS2005).
>
> Thanks,
> Nate
>
>
> [1] <http://lists.boost.org/boost-users/2010/06/60066.php>
> [2] <http://lists.boost.org/Archives/boost/2010/07/169159.php>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


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