Whoops, the diff was cut off.  Here's the full diff, on the off chance you need it:

diff --git a/include/boost/gil/channel_algorithm.hpp b/include/boost/gil/channel_algorithm.hpp

index 1361219..1799470 100644

--- a/include/boost/gil/channel_algorithm.hpp

+++ b/include/boost/gil/channel_algorithm.hpp

@@ -51,7 +51,7 @@ template <typename SrcChannelV, typename DstChannelV, bool SrcLessThanDst, bool



 template <typename UnsignedIntegralChannel>

-struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};

+struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,(1<<sizeof(UnsignedIntegralChannel))-1> {};


 template <>

 struct unsigned_integral_max_value<uint8_t> : public mpl::integral_c<uint32_t,0xFF> {};

HTH,

Nate



On Mon, Jan 12, 2015 at 2:04 PM, Nate Crookston <nathan.crookston@gmail.com> wrote:
Hi Gabriel,

I've successfully done what you're trying to do I think.  I wrote about some problems in the following thread: https://groups.google.com/forum/#!topic/boost-list/4CqibxPFdUw.  In short, I had to specialize a few other metafunctions.  I think we should add a scoped_integral_channel_value type which has appropriate specializations for people trying to do what you're doing.

I had to make the following change to compile with c++11 clang:

diff --git a/include/boost/gil/channel_algorithm.hpp b/include/boost/gil/channel_algorithm.hpp

index 1361219..1799470 100644

--- a/include/boost/gil/channel_algorithm.hpp

+++ b/include/boost/gil/channel_algorithm.hpp

@@ -51,7 +51,7 @@ template <typename SrcChannelV, typename DstChannelV, bool SrcLessThanDst, bool

 

 

 template <typename UnsignedIntegralChannel>

-struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,-1> {};

+struct unsigned_integral_max_value : public mpl::integral_c<UnsignedIntegralChannel,(1<<sizeof(Un

 

 template <>

 struct unsigned_integral_max_value<uint8_t> : public mpl::integral_c<uint32_t,0xFF> {};


Then I added a couple specializations in your code:


#include <boost/gil/gil_all.hpp>

#include <cstdint>


using namespace std;

using namespace boost::gil;


namespace detail

{

    struct bits14_min { static std::uint16_t apply() { return 0;} };

    struct bits14_max { static std::uint16_t apply() { return 0x3FF;} };

}


typedef scoped_channel_value <std::uint16_t, ::detail::bits14_min, ::detail::bits14_max> bits14_t;

namespace boost { namespace gil { namespace detail {

  template <> struct unsigned_integral_max_value<bits14_t> : public mpl::integral_c<uint32_t,0x3FF> {};

  template <> struct unsigned_integral_num_bits<bits14_t> : public mpl::int_<14> {};

}}}


typedef pixel<bits14_t, gray_layout_t> Pixel1;

typedef image<Pixel1> Frame1;


int main()

{

  bits14_t x = channel_traits<bits14_t>::max_value();

  assert(x == 0x3ff);

  bits16 y = channel_convert<bits16>(x);

  assert(y == 0xffff);


  Frame1 image(

      Frame1::point_t(100, 100),

      Frame1::value_type((1 << 14)-1),

      0);


  gray16_image_t image2(image.dimensions());


  Frame1::view_t view1(view(image));

  gray16_image_t::view_t view2(view(image2));


  copy_and_convert_pixels(view1, view2);

  return 0;

}



On Thu, Jan 8, 2015 at 4:13 PM, Gabriel Marcano <gabemarcano@yahoo.com> wrote:
I have been experimenting with Boost.GIL, and I have run into something
that I'm not sure if it's a problem on my end or with Boost.GIL. In
essence, I'm trying to make a grayscale image with channels limited to
14 bits. I am using scoped_channel_value to do this. The problem
happens when I try to convert the 14 bit image to a 16 bit grayscale
image I get compilation errors. I am including the code I am using
below:

//START CODE

    #include <boost/gil/gil_all.hpp>
    #include <cstdint>

    using namespace std;
    using namespace boost::gil;

    namespace detail
    {
        struct bits14_min { static std::uint16_t apply() { return 0;} };
        struct bits14_max
           { static std::uint16_t apply() { return 0x3FF;} };
    }

    typedef scoped_channel_value
        <std::uint16_t,
            ::detail::bits14_min, ::detail::bits14_max> bits14_t;

    typedef pixel<bits14_t, gray_layout_t> Pixel1;
    typedef image<Pixel1> Frame1;

    int main()
    {
        Frame1 image(
            Frame1::point_t(100, 100),
            Frame1::value_type((1 << 14)-1),
            0);

        gray16_image_t image2(image.dimensions());

        Frame1::view_t view1(view(image));
        gray16_image_t::view_t view2(view(image2));

        copy_and_convert_pixels(view1, view2);

        return 0;
    }

//END CODE

The interesting thing is that the program compiles if change
    typedef scoped_channel_value
        <std::uint16_t,
            ::detail::bits14_min, ::detail::bits14_max> bits14_t;
to
    typedef scoped_channel_value
        <float,
            ::detail::bits14_min, ::detail::bits14_max> bits14_t;

I think the relevant error in the log is this:
    /usr/include/boost/gil/channel_algorithm.hpp:54:8: error:
        ‘struct boost::gil::scoped_channel_value<short unsigned
        int, detail::bits14_min, detail::bits14_max>’ is not a
        valid type for a template non-type parameter
         struct unsigned_integral_max_value : public
             mpl::integral_c<UnsignedIntegralChannel,-1> {};

I am attaching the full compile log to this email. Thank you for any
help with this matter!

Sincerely,

Gabriel E. Marcano

_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users