Boost logo

Boost Users :

Subject: Re: [Boost-users] [GIL] Adding base_channel_type metafunction
From: Nathan Crookston (nathan.crookston_at_[hidden])
Date: 2010-11-04 01:33:40


Hi Christian,

On Tue, Nov 2, 2010 at 9:38 AM, Christian Henning <chhenning_at_[hidden]> wrote:
> Hi Nate, good to hear from you!
Likewise.

>
> 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.
I've reproduced the issues with both boost 1.44 and the current trunk
using VC8 (VS2005). Interestingly, the issues don't appear with VC10
nor with g++.

>
> 2. Could you send me a small test code that exhibits your problem?
I should have done this initially. The following code gives me
warnings when compiled with cl.exe /EHsc /W4 <filename>
/I<path-to-boost>

/////////BEGIN CODE////////////
#include <boost/gil/gil_all.hpp>
#include <iostream>

namespace boost { namespace gil {
//////////////////////////////////////////////////////////////////////////
// Byte-aligned 12 bit grayscale
//////////////////////////////////////////////////////////////////////////
const uint16_t bits12_max_val = 0xFFF;
struct bits12_min { static uint16_t apply() { return 0; } };
struct bits12_max { static uint16_t apply() { return bits12_max_val; } };

typedef scoped_channel_value<uint16_t, bits12_min, bits12_max> bits12;

namespace detail
{
template <>
struct unsigned_integral_max_value<bits12>
  : public mpl::integral_c<uint32_t, bits12_max_val> {};

template <>
struct unsigned_integral_num_bits<bits12> : public mpl::int_<12> {};

}//end detail

GIL_DEFINE_BASE_TYPEDEFS(12, gray)
} }//end boost::gil

namespace gil = boost::gil;

int main()
{
  gil::gray12_pixel_t g14(100);
  gil::rgb8_pixel_t rgb8;

  color_convert(g14, rgb8);
  color_convert(rgb8, g14);

  return 0;
}

/////////END CODE////////////

The problem appears to that the scoped_channel_value constructor
expects either a scoped_channel_value object or an object of type
base_channel_t. While the channel conversion code ensures the output
will be valid (assuming valid input), it doesn't cast it to the type
the channel is expecting.

A small warning snippet:
c:\cygwin\home\ncrookston\boost_trunk\boost\gil\channel_algorithm.hpp(230)
: warning C4244: 'argument' : conversion from 'integer_t' to
'boost::uint16_t', possible loss of data

NOTE: The patch I sent earlier has an error -- in copying my changes
from 1.44 to the trunk I failed to replace value_type with type in a
couple places. The patch attached to this email corrects that.

Thanks,
Nate




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