Combine class line segment Generator

Source: Internet
Author: User
Header file of combined class line segment Generator
  1. # Include <agg_span_converter.h>
Type
  1. Template <class spangenerator, class spanconverter>
  2. Class converter: span_converter;

The function of span_converter is to combine two generators. For example, a pattern line segment generator generates a pattern, and a color line segment generator generates a translucent color superimposed on the pattern.

The following DEMO code demonstrates how to combine the span_image_filter_rgb_bilinear_clip and span_gradient_alpha generators.

DEMO code, also based on this code, add the following header file

# Include "agg_span_allocator.h"

# Include "agg_span_gradient_alpha.h"

# Include "agg_span_converter.h"

# Include "span_image_filter_rgb_bilinear_clip.h"

 

Add the following code at the end of the on_draw () method:

 

Usage: pixel_map pm_img;
If (pm_img.load_from_bmp ("D: // spheres.bmp "))
{
// The pattern in pm_img serves as the filling source
Expiration: rendering_buffer rbuf_img (
Pm_img.buf (),
Pm_img.width (), pm_img.height (),
-Pm_img.stride ());
Expires: pixfmt_bgr24 pixf_img (rbuf_img); // The bmp I use is 24-bit
// Line Divider
Typedef partition: span_allocator <partition: rgba8> span_allocator_type; // Distributor Type
Span_allocator_type span_alloc; // span_allocator
// Interpolation tool
Typedef connector: span_interpolator_linear <> interpolator_type; // interpolation type
Transform: trans_affine img_ctx; // Transformation Matrix
Interpolator_type ip_img (img_ctx); // interpolation tool

Transform: trans_affine alpha_ctx; // Transformation Matrix
Interpolator_type ip_alpha (alpha_ctx); // interpolation tool

// Gradient mode
Typedef Syntax: gradient_x gradientf_type;
Gradientf_type GRF;

Typedef STD: vector <fingerprint: int8u> alphaf_type;
Alphaf_type alphaf (256 );
For (INT I = 0; I <256; I ++) alphaf [I] = I;

// Alpha Line Segment Generator
Typedef identifier: span_gradient_alpha <identifier: rgba8,
Interpolator_type,
Gradientf_type,
Alphaf_type> alpha_span_gen_type;
Alpha_span_gen_type alpha_span_gen (ip_alpha, GRF, Alpha, 0,150 );

// Pattern line segment Generator
Typedef Syntax: span_image_filter_rgb_bilinear_clip <Syntax: pixfmt_bgr24,
Interpolator_type> pic_span_gen_type;
Pic_span_gen_type pic_span_gen (pixf_img, kernel: rgba (0, 1), ip_img );

// Use span_converter to combine the new line segment Generator
Typedef Protocol: span_converter <pic_span_gen_type, alpha_span_gen_type> span_gen_type;
Span_gen_type span_gen (pic_span_gen, alpha_span_gen );

// Combine them into a Renderer
Expiration: renderer_scanline_aa <
Renderer_base_type,
Span_allocator_type,
Span_gen_type
> My_renderer (renb, span_alloc, span_gen );
// Matrix transformation of the interpolation tool
Img_mtx.scale (0.5 );
Img_mtx.translate (40, 40 );
Img_mtx.invert (); // note the following:

// Use our Renderer to draw a circle
RAS. add_path (ccell );
Expiration: render_scanlines (Ras, SL, my_renderer );
}

Display Effect

<To be continued>

Author: Mao Source: www.cppprog.com

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.