typename PixelRef::value_type operator()( const PixelRef& p) { typename PixelRef::value_type r; get_color( r, red_t()) = channel_multiply( get_color( p, red_t()), get_color( p, alpha_t())); get_color( r, green_t()) = channel_multiply( get_color( p, green_t()), get_color( p, alpha_t())); get_color( r, blue_t()) = channel_multiply( get_color( p, blue_t()), get_color( p, alpha_t())); get_color( r, alpha_t()) = get_color( p, alpha_t()); return r; }
void operator()(const P1& src, P2& dst) const { get_color(dst,red_t()) = channel_convert<typename color_element_type<P2, red_t>::type>( channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) ) ); get_color(dst,green_t()) = channel_convert<typename color_element_type<P2, green_t>::type>( channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) ) ); get_color(dst,blue_t()) = channel_convert<typename color_element_type<P2, blue_t>::type>( channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) ) ); }
void operator()(const SrcP& src, DstP& dst) const { typedef typename color_space_type<SrcP>::type src_colour_space_t; typedef typename color_space_type<DstP>::type dst_colour_space_t; typedef typename mpl:: remove <src_colour_space_t, alpha_t>:: type src_colour_channels; mpl:: for_each <src_colour_channels> ( channel_premultiply <SrcP, DstP> (src, dst) ); if (mpl:: contains <dst_colour_space_t, alpha_t>:: value) get_color (dst,alpha_t()) = alpha_or_max (src); }
void operator()(const P1& src, P2& dst) const { typedef typename channel_type<P1>::type T1; default_color_converter_impl<cmyk_t,C2>()( pixel<T1,cmyk_layout_t>(channel_multiply(get_color(src,cyan_t()), get_color(src,alpha_t())), channel_multiply(get_color(src,magenta_t()),get_color(src,alpha_t())), channel_multiply(get_color(src,yellow_t()), get_color(src,alpha_t())), channel_multiply(get_color(src,black_t()), get_color(src,alpha_t()))) ,dst); }
void invert_alpha( const RGBAView& dst) { for( int y = 0; y < dst.dimensions().y; ++y ) { typename RGBAView::x_iterator dst_it = dst.row_begin( y ); for( int x = 0; x < dst.dimensions().x; ++x ) get_color( dst_it[x], alpha_t() ) = channel_invert( get_color( dst_it[x], alpha_t())); } }
void set_alpha( const RGBAView& dst, Channel value) { for( int y = 0; y < dst.dimensions().y; ++y ) { typename RGBAView::x_iterator dst_it = dst.row_begin( y ); for( int x = 0; x < dst.dimensions().x; ++x ) get_color( dst_it[x], alpha_t() ) = value; } }
void copy_alpha( const RGBAView& dst, const GrayView& src) { for( int y = 0; y < dst.dimensions().y; ++y ) { typename GrayView::x_iterator src_it = src.row_begin( y ); typename RGBAView::x_iterator dst_it = dst.row_begin( y ); for( int x = 0; x < dst.dimensions().x; ++x ) get_color( dst_it[x], alpha_t() ) = src_it[x][0]; } }
void operator()(const P1& src, P2& dst) const { get_color(dst,red_t()) = channel_convert<typename color_element_type<P2, red_t >::type>(get_color(src,gray_color_t())); get_color(dst,green_t())= channel_convert<typename color_element_type<P2, green_t>::type>(get_color(src,gray_color_t())); get_color(dst,blue_t()) = channel_convert<typename color_element_type<P2, blue_t >::type>(get_color(src,gray_color_t())); typedef typename channel_type< P2 >::type channel_t; get_color(dst,alpha_t()) = channel_traits< channel_t >::max_value(); }
typename PixelRef::value_type operator()( const PixelRef& p) { typename PixelRef::value_type r; typename PixelRef::channel_t a; a = get_color( p, alpha_t()); if( a != 0) { get_color( r, red_t()) = chan_divide( get_color( p, red_t()), a); get_color( r, green_t()) = chan_divide( get_color( p, green_t()), a); get_color( r, blue_t()) = chan_divide( get_color( p, blue_t()), a); get_color( r, alpha_t()) = a; } else { get_color( r, red_t()) = 0; get_color( r, green_t()) = 0; get_color( r, blue_t()) = 0; get_color( r, alpha_t()) = 0; } return r; }
/// Split RGBA to RGBA components static void split(const pixel_t& p, channel_t& r, channel_t& g, channel_t& b, channel_t& a) throw() { r = get_color(p, red_t()); g = get_color(p, green_t()); b = get_color(p, blue_t()); a = get_color(p, alpha_t()); }