|
Boost Users : |
From: Christian Henning (chhenning_at_[hidden])
Date: 2007-05-04 22:39:49
Seems that my questions got unnoticed. I still haven't found a
solutiont bind gil::at_c() yet. But also for gil::dynamic_at_c() it is
not working.
As a workaround I created the code below. But still maybe somebody
knows how to do it.
Thanks,
Christian
using namespace std;
using namespace boost;
using namespace gil;
template< typename CHANNEL
, typename COLORBASE
>
inline
CHANNEL& get_channel_0( COLORBASE& cb )
{
return gil::at_c<0>( cb );
}
template < typename CHANNEL >
inline
void set_zero( CHANNEL& c )
{
c = 0;
}
int main()
{
rgb8_image_t src;
bmp_read_image( ".\\flower.bmp", src );
typedef channel_type<rgb8_pixel_t>::type channel_t;
typedef channel_t& (*AA)( rgb8_pixel_t& );
typedef void (*BB)( channel_t& );
for_each( view( src ).begin()
, view( src ).end()
, bind( static_cast<BB>( &set_zero )
, bind( static_cast<AA>( &get_channel_0<channel_t> ), _1 )));
bmp_write_view( ".\\flower_no_red_channel.bmp"
, view( src ));
return 0;
}
On 4/29/07, Christian Henning <chhenning_at_[hidden]> wrote:
> Hi there my compiler doesn't like binding the gil::at_c function. I'm
> using MSVC 7.1 SP1. Please correct if I'm wrong but I think you need
> to supply a function pointer cast for overloaded function when using
> this compiler. But for some reasons I cannot make it happen.
>
> template < typename CHANNEL >
> void set_zero( CHANNEL c )
> {
> c = 0;
> }
>
>
> int main()
> {
>
> rgb8_image_t src;
> bmp_read_image( ".\\flower.bmp", src );
>
> typedef channel_type<rgb8_pixel_t>::type return_t;
> add_reference<return_t>::type (*AA)( rgb8_pixel_t& ) = &gil::at_c<0>;
>
> for_each( view( src ).begin()
> , view( src ).end()
> , bind( &set_zero, bind( AA, _1 )));
>
>
> return 0;
> }
>
> compiler error is:
>
> \gil\repos\gil_2\libs\gil\toolbox\test.cpp(74) : error C2440:
> 'initializing' : cannot convert from 'overloaded-function' to
> 'boost::add_reference<T>::type (__cdecl *)(boost::gil::rgb8_pixel_t
> &)'
> with
> [
> T=boost::gil::bits8
> ]
> None of the functions with this name in scope match the target type
>
>
> Thanks ahead,
> Christian
>
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