Пример #1
0
void recaptcha::render(cppcms::form_context& context)
{
	auto_generate(&context);
	context.widget_part(first_part);
	render_input(context);
	context.widget_part(second_part);
	render_input(context);

}
Пример #2
0
void key_mix_layer_node_t::do_process( const render::context_t& context)
{
    image_node_t *bg = input_as<image_node_t>( 0);
    image_node_t *fg = input_as<image_node_t>( 1);
    image_node_t *mt = input_as<image_node_t>( 2);

    Imath::Box2i bg_area = Imath::intersect( bg->defined(), defined());

    if( !bg_area.isEmpty())
    {
        render_input( 0, context);
		boost::gil::copy_pixels( bg->const_subimage_view( bg_area), subimage_view( bg_area));
        release_input_image( 0);
    }

    Imath::Box2i comp_area( Imath::intersect( Imath::intersect( fg->defined(), mt->defined()), defined()));

    if( !comp_area.isEmpty())
    {
        render_input( 1, context);

        // image buffer contains a shared ptr to
        // the actual pixels. Saving it to a local variable,
        // is equivalent to locking the pixels.
        // This could be improved, as I think it's not really clear.
        // There is also a lock method in buffer_t that it's
        // currently unused...
        image::buffer_t fg_img = fg->image();

        render_input( 2, context);
        image::buffer_t alpha_img = mt->image();

		boost::gil::tbb_transform3_pixels( const_subimage_view( comp_area),
											fg->const_subimage_view( comp_area),
											mt->const_subimage_view( comp_area),
											subimage_view( comp_area),
											key_mix_layer_mode_fun( get_value<float>( param( "opacity"))));
        release_input_image( 1);
        release_input_image( 2);
    }
}
Пример #3
0
string base_widget::render(int how)
{
	string out;
	string input=render_input(how);
	string error;

	switch(how & error_mask) {
	case error_with:
		error=render_error();
		break;
	case error_no:
		break;
	}

	string tmp_msg;
	if(!msg.empty()){
		if(!id.empty()) {
			tmp_msg+="<lablel for=\"";
			tmp_msg+=id;
			tmp_msg+="\">";
			tmp_msg+=escape(msg);
			tmp_msg+=":</label>";
		}
		else {
			tmp_msg=escape(msg);
			tmp_msg+=":";
		}
	}

	string help_text;

	if(!help.empty()) {
		if((how & as_mask)==as_table)
			help_text=
				((how & as_xhtml) ? "<br/>" : "<br>") 
				+ escape(help);
		else
			help_text=escape(help);
	}
		
	if(error.empty()) {
		char const *frm=NULL;
		switch(how & as_mask) {
		case as_p: 
			frm = "<p>%1% %2% %3%</p>\n";
			break;
		case as_table:
			frm = "<tr><th>%1%</th><td>%2% %3%</td></tr>\n";
			break;
		case as_ul:
			frm = "<li>%1% %2% %3%</li>\n";
			break;
		case as_dl:
			frm = "<dt>%1%</dt>\n<dd>%2% %3%</dd>\n";
			break;
		case as_space:
			frm = "%1% %2% %3%\n";
			break;
		}
		assert(frm);
		out=(boost::format(frm) % tmp_msg % input % help_text).str();
	}
	else {
		char const *frm=NULL;
		switch(how & as_mask) {
		case as_p: 
			frm = "<p>%3%</p>\n<p>%1% %2% %4%</p>\n";
			break;
		case as_table:
			frm = "<tr><th>%1%</th><td>%3% %2% %4%</td></tr>\n";
			break;
		case as_ul:
			frm = "<li>%3% %1% %2% %4%</li>\n";
			break;
		case as_dl:
			frm = "<dt>%3% %1%</dt>\n<dd>%2% %4%</dd>\n";
			break;
		case as_space:
			frm = "%3% %1% %2% %4%\n";
			break;
		}
		assert(frm);
		error="<span class=\"formerror\">" + error + "</span>";
		out=(boost::format(frm) % tmp_msg % input % error % help_text).str();
	}
	return out;
}
Пример #4
0
void layer_node_t::do_process( const render::context_t& context)
{
    int mode = get_value<int>( param( "layer_mode"));

    if( mode == comp_mult || mode == comp_min || mode == comp_overlay || mode == comp_mix) // min, mult and overlay are special
    {
        do_process_mult_min_overlay_mix( context);
        return;
    }

    image_node_t *bg = input_as<image_node_t>( 0);
    image_node_t *fg = input_as<image_node_t>( 1);

    Imath::Box2i bg_area = ImathExt::intersect( bg->defined(), defined());
    float opacity = get_value<float>( param( "opacity"));

    if( !bg_area.isEmpty())
    {
        render_input( 0, context);
        boost::gil::copy_pixels( bg->const_subimage_view( bg_area), subimage_view( bg_area));
        release_input_image( 0);
    }

    Imath::Box2i comp_area( ImathExt::intersect( fg->defined(), defined()));

    if( !comp_area.isEmpty())
    {
        if( opacity == 0.0f)
            return;

        render_input( 1, context);

        switch( mode)
        {
        case comp_over:
            image::composite_over( const_subimage_view( comp_area), 
								   input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								   subimage_view( comp_area), opacity);
        break;

        case comp_add:
            image::composite_add( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;

        case comp_sub:
            image::composite_sub( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;

        case comp_screen:
            image::composite_screen( const_subimage_view( comp_area), 
									 input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
									 subimage_view( comp_area), opacity);
        break;

        case comp_overlay:
            image::composite_overlay( const_subimage_view( comp_area), 
									  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
									  subimage_view( comp_area), opacity);
        break;

        case comp_diff:
            image::composite_diff( const_subimage_view( comp_area), 
								   input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								   subimage_view( comp_area), opacity);
        break;

        case comp_max:
            image::composite_max( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;
        }

        release_input_image( 1);
    }
}
Пример #5
0
void layer_node_t::do_process_mult_min_overlay_mix( const render::context_t& context)
{
    image_node_t *bg = input_as<image_node_t>( 0);
    image_node_t *fg = input_as<image_node_t>( 1);

    int mode = get_value<int>( param( "layer_mode"));
    float opacity = get_value<float>( param( "opacity"));

    Imath::Box2i bg_area(   ImathExt::intersect( bg->defined(), defined()));
    Imath::Box2i comp_area( ImathExt::intersect( fg->defined(), defined()));

    if( !bg_area.isEmpty())
    {
        render_input( 0, context);

        if( opacity == 0.0f) // just copy the background and return
        {
            boost::gil::copy_pixels( bg->const_subimage_view( bg_area), subimage_view( bg_area));
            return;
        }

        if( mode == comp_overlay)
        {
            image::composite_zero_overlay( bg->const_subimage_view( bg_area), subimage_view( bg_area), opacity);

            Imath::Box2i common_area( ImathExt::intersect( fg->defined(), bg->defined()));

            if( !common_area.isEmpty())
                boost::gil::copy_pixels( bg->const_subimage_view( common_area), subimage_view( common_area));
        }
        else
        {
            if( opacity == 1.0f) // the normal case, nothing special to do
                boost::gil::copy_pixels( bg->const_subimage_view( bg_area), subimage_view( bg_area));
            else // we need to handle the areas of the bg that don't intersect the fg
            {
                image::mul_image_scalar( bg->const_subimage_view( bg_area), 1.0f - opacity, subimage_view( bg_area));

                Imath::Box2i common_area( ImathExt::intersect( fg->defined(), bg->defined()));

                if( !common_area.isEmpty())
                    boost::gil::copy_pixels( bg->const_subimage_view( common_area), subimage_view( common_area));
            }
        }

        // we don't need the bg anymore
        release_input_image( 0);
    }

    if( !comp_area.isEmpty())
    {
        render_input( 1, context);

        switch( mode)
        {
        case comp_min:
            image::composite_min( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;

        case comp_mult:
            image::composite_mul( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;

        case comp_mix:
            image::composite_mix( const_subimage_view( comp_area), 
								  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
								  subimage_view( comp_area), opacity);
        break;

        case comp_overlay:
            image::composite_overlay( const_subimage_view( comp_area), 
									  input_as<image_node_t>( 1)->const_subimage_view( comp_area), 
									  subimage_view( comp_area), opacity);
        break;
        }

        release_input_image( 1);
    }
}