Boost logo

Boost Users :

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


Christan,

Thanks for looking over my patch.

On Sun, Nov 7, 2010 at 12:39 AM, Nathan Crookston
> I have an updated patch which fixes the above problem and also
> prevents a few more warnings.
>
> Since I dislike large amounts of code in a single message I'll send
> another shortly, describing how to reproduce the warning and with
> another patch which should correct it and everything else discussed
> thus far.

The following code reveals another place where we GIL can emit
warnings (at an admittedly high warning level):

///BEGIN CODE showing channel conversion problems for large integers///
#include <boost/gil/gil_all.hpp>
#include <iostream>

namespace boost { namespace gil {
//////////////////////////////////////////////////////////////////////////
// Byte-aligned 30 bit grayscale
//////////////////////////////////////////////////////////////////////////
const uint64_t bits60_max_val = 1152921504606846976;
struct bits60_min { static uint64_t apply() { return 0; } };
struct bits60_max { static uint64_t apply() { return bits60_max_val; } };

typedef scoped_channel_value<uint64_t, bits60_min, bits60_max> bits60;

namespace detail
{
template <>
struct unsigned_integral_max_value<bits60>
  : public mpl::integral_c<uint64_t, bits60_max_val> {};

template <>
struct unsigned_integral_num_bits<bits60> : public mpl::int_<60> {};

}//end detail

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

namespace gil = boost::gil;

int main()
{
  gil::gray60_pixel_t g60;
  gil::gray8_pixel_t g8(255);

  color_convert(g8, g60);

  std::cout << "Value: " << g60[0] << std::endl;
  std::cout << "Should be: " << gil::bits60_max_val << std::endl;

  return 0;
}

///END CODE///

The fix is the same as it's been for the other warnings.

The attached patch corrects this, the original conversion problems and
an actual bug as noted in my previous message. It also fixes the
issue with my original patch (use type, not value_type -- thanks for
catching that, I incorrectly merged my changes from 1.44 to trunk
before generating the patch).

Please let me know if there are any problems, thanks again!

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