internal ImageRenderer(ImageBuffer owner) : base() { m_Owner = owner; rasterizer_scanline_aa rasterizer = new rasterizer_scanline_aa(); ImageClippingProxy imageClippingProxy = new ImageClippingProxy(owner); Initialize(imageClippingProxy, rasterizer); ScanlineCache = new scanline_packed_8(); }
public RendererOpenGL(IPixelFormat PixelFormat, rasterizer_scanline_aa Rasterizer) : base(PixelFormat, Rasterizer) { TextPath = new gsv_text(); StrockedText = new conv_stroke(TextPath); }
public override void on_draw() { pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr()); renderer_base ren_base = new renderer_base(pf); ren_base.clear(new rgba(1.0, 1.0, 0.95)); renderer_scanline_aa_solid ren = new renderer_scanline_aa_solid(ren_base); rasterizer_scanline_aa ras = new rasterizer_scanline_aa(); scanline_unpacked_8 sl = new scanline_unpacked_8(); path_storage path = new path_storage(new vertex_block_storage()); double x, y; double curve_time = 0; path.remove_all(); curve4 curve; curve.approximation_method(curve_approximation_method_e(m_curve_type.cur_item())); curve.approximation_scale(m_approximation_scale.value()); curve.angle_tolerance(deg2rad(m_angle_tolerance.value())); curve.cusp_limit(deg2rad(m_cusp_limit.value())); curve_time = measure_time(curve); double max_angle_error_01 = 0; double max_angle_error_1 = 0; double max_angle_error1 = 0; double max_angle_error_10 = 0; double max_angle_error_100 = 0; double max_error_01 = 0; double max_error_1 = 0; double max_error1 = 0; double max_error_10 = 0; double max_error_100 = 0; max_error_01 = calc_max_error(curve, 0.01, &max_angle_error_01); max_error_1 = calc_max_error(curve, 0.1, &max_angle_error_1); max_error1 = calc_max_error(curve, 1, &max_angle_error1); max_error_10 = calc_max_error(curve, 10, &max_angle_error_10); max_error_100 = calc_max_error(curve, 100, &max_angle_error_100); curve.approximation_scale(m_approximation_scale.value()); curve.angle_tolerance(deg2rad(m_angle_tolerance.value())); curve.cusp_limit(deg2rad(m_cusp_limit.value())); curve.init(m_curve1.x1(), m_curve1.y1(), m_curve1.x2(), m_curve1.y2(), m_curve1.x3(), m_curve1.y3(), m_curve1.x4(), m_curve1.y4()); path.concat_path(curve); //path.move_to(m_curve1.x1(), m_curve1.y1()); //path.line_to(m_curve1.x2(), m_curve1.y2()); //path.line_to(m_curve1.x3(), m_curve1.y3()); //path.line_to(m_curve1.x4(), m_curve1.y4()); conv_stroke stroke = new conv_stroke(path); stroke.width(m_width.value()); stroke.line_join(line_join_e(m_line_join.cur_item())); stroke.line_cap(line_cap_e(m_line_cap.cur_item())); stroke.inner_join(inner_join_e(m_inner_join.cur_item())); stroke.inner_miter_limit(1.01); ras.add_path(stroke); ren.color(rgba(0, 0.5, 0, 0.5)); render_scanlines(ras, sl, ren); uint cmd; uint num_points1 = 0; path.rewind(0); while (!is_stop(cmd = path.vertex(&x, &y))) { if (m_show_points.status()) { Shape.Ellipse ell = new agg.Shape.Ellipse(x, y, 1.5, 1.5, 8); ras.add_path(ell); ren.color(rgba(0, 0, 0, 0.5)); render_scanlines(ras, sl, ren); } ++num_points1; } if (m_show_outline.status()) { // Draw a stroke of the stroke to see the internals //-------------- conv_stroke stroke2 = new conv_stroke(stroke); ras.add_path(stroke2); ren.color(rgba(0, 0, 0, 0.5)); render_scanlines(ras, sl, ren); } // Check ellipse and arc for the number of points //--------------- //ellipse a(100, 100, m_width.value(), m_width.value(), 0); //ras.add_path(a); //ren.color(rgba(0.5,0,0, 0.5)); //render_scanlines(ras, sl, ren); //a.rewind(0); //while(!is_stop(cmd = a.vertex(&x, &y))) //{ // if(is_vertex(cmd)) // { // ellipse ell(x, y, 1.5, 1.5, 8); // ras.add_path(ell); // ren.color(rgba(0,0,0,0.5)); // render_scanlines(ras, sl, ren); // } //} // Check a circle with huge radius (10,000,000) and high approximation accuracy //--------------- //double circle_pnt_count = 0; //bezier_arc ell(0,0, 10000000, 10000000, 0, 2*pi); //conv_curve<bezier_arc, curve3_div, curve4_div3> crv(ell); //crv.approximation_scale(10.0); //crv.rewind(0); //while(crv.vertex(&x, &y)) ++circle_pnt_count; string buf; gsv_text t; t.size(8.0); conv_stroke pt = new conv_stroke(t); pt.line_cap(round_cap); pt.line_join(round_join); pt.width(1.5); /* * sprintf(buf, "Num Points=%d Time=%.2fmks\n\n" * " Dist Error: x0.01=%.5f x0.1=%.5f x1=%.5f x10=%.5f x100=%.5f\n\n" * "Angle Error: x0.01=%.1f x0.1=%.1f x1=%.1f x10=%.1f x100=%.1f", * num_points1, curve_time, * max_error_01, * max_error_1, * max_error1, * max_error_10, * max_error_100, * max_angle_error_01, * max_angle_error_1, * max_angle_error1, * max_angle_error_10, * max_angle_error_100); */ t.start_point(10.0, 85.0); t.text(buf); ras.add_path(pt); ren.color(rgba(0, 0, 0)); render_scanlines(ras, sl, ren); render_ctrl(ras, sl, ren_base, m_curve1); render_ctrl(ras, sl, ren_base, m_angle_tolerance); render_ctrl(ras, sl, ren_base, m_approximation_scale); render_ctrl(ras, sl, ren_base, m_cusp_limit); render_ctrl(ras, sl, ren_base, m_width); render_ctrl(ras, sl, ren_base, m_show_points); render_ctrl(ras, sl, ren_base, m_show_outline); render_ctrl(ras, sl, ren_base, m_curve_type); render_ctrl(ras, sl, ren_base, m_case_type); render_ctrl(ras, sl, ren_base, m_inner_join); render_ctrl(ras, sl, ren_base, m_line_join); render_ctrl(ras, sl, ren_base, m_line_cap); }
public void Initialize(IImage DestImage, rasterizer_scanline_aa Rasterizer) { m_DestImage = DestImage; m_Rasterizer = Rasterizer; }
public override void on_draw() { pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(rbuf_window(), new blender_bgr()); renderer_base ren_base = new renderer_base(pf); ren_base.clear(new rgba(1.0, 1.0, 0.95)); renderer_scanline_aa_solid ren = new renderer_scanline_aa_solid(ren_base); rasterizer_scanline_aa ras = new rasterizer_scanline_aa(); scanline_unpacked_8 sl = new scanline_unpacked_8(); path_storage path = new path_storage(new vertex_block_storage()); double x, y; double curve_time = 0; path.remove_all(); curve4 curve; curve.approximation_method(curve_approximation_method_e(m_curve_type.cur_item())); curve.approximation_scale(m_approximation_scale.value()); curve.angle_tolerance(deg2rad(m_angle_tolerance.value())); curve.cusp_limit(deg2rad(m_cusp_limit.value())); curve_time = measure_time(curve); double max_angle_error_01 = 0; double max_angle_error_1 = 0; double max_angle_error1 = 0; double max_angle_error_10 = 0; double max_angle_error_100 = 0; double max_error_01 = 0; double max_error_1 = 0; double max_error1 = 0; double max_error_10 = 0; double max_error_100 = 0; max_error_01 = calc_max_error(curve, 0.01, &max_angle_error_01); max_error_1 = calc_max_error(curve, 0.1, &max_angle_error_1); max_error1 = calc_max_error(curve, 1, &max_angle_error1); max_error_10 = calc_max_error(curve, 10, &max_angle_error_10); max_error_100 = calc_max_error(curve, 100, &max_angle_error_100); curve.approximation_scale(m_approximation_scale.value()); curve.angle_tolerance(deg2rad(m_angle_tolerance.value())); curve.cusp_limit(deg2rad(m_cusp_limit.value())); curve.init(m_curve1.x1(), m_curve1.y1(), m_curve1.x2(), m_curve1.y2(), m_curve1.x3(), m_curve1.y3(), m_curve1.x4(), m_curve1.y4()); path.concat_path(curve); //path.move_to(m_curve1.x1(), m_curve1.y1()); //path.line_to(m_curve1.x2(), m_curve1.y2()); //path.line_to(m_curve1.x3(), m_curve1.y3()); //path.line_to(m_curve1.x4(), m_curve1.y4()); conv_stroke stroke = new conv_stroke(path); stroke.width(m_width.value()); stroke.line_join(line_join_e(m_line_join.cur_item())); stroke.line_cap(line_cap_e(m_line_cap.cur_item())); stroke.inner_join(inner_join_e(m_inner_join.cur_item())); stroke.inner_miter_limit(1.01); ras.add_path(stroke); ren.color(rgba(0, 0.5, 0, 0.5)); render_scanlines(ras, sl, ren); uint cmd; uint num_points1 = 0; path.rewind(0); while(!is_stop(cmd = path.vertex(&x, &y))) { if(m_show_points.status()) { Shape.Ellipse ell = new agg.Shape.Ellipse(x, y, 1.5, 1.5, 8); ras.add_path(ell); ren.color(rgba(0,0,0, 0.5)); render_scanlines(ras, sl, ren); } ++num_points1; } if(m_show_outline.status()) { // Draw a stroke of the stroke to see the internals //-------------- conv_stroke stroke2 = new conv_stroke(stroke); ras.add_path(stroke2); ren.color(rgba(0,0,0, 0.5)); render_scanlines(ras, sl, ren); } // Check ellipse and arc for the number of points //--------------- //ellipse a(100, 100, m_width.value(), m_width.value(), 0); //ras.add_path(a); //ren.color(rgba(0.5,0,0, 0.5)); //render_scanlines(ras, sl, ren); //a.rewind(0); //while(!is_stop(cmd = a.vertex(&x, &y))) //{ // if(is_vertex(cmd)) // { // ellipse ell(x, y, 1.5, 1.5, 8); // ras.add_path(ell); // ren.color(rgba(0,0,0,0.5)); // render_scanlines(ras, sl, ren); // } //} // Check a circle with huge radius (10,000,000) and high approximation accuracy //--------------- //double circle_pnt_count = 0; //bezier_arc ell(0,0, 10000000, 10000000, 0, 2*pi); //conv_curve<bezier_arc, curve3_div, curve4_div3> crv(ell); //crv.approximation_scale(10.0); //crv.rewind(0); //while(crv.vertex(&x, &y)) ++circle_pnt_count; string buf; gsv_text t; t.size(8.0); conv_stroke pt = new conv_stroke(t); pt.line_cap(round_cap); pt.line_join(round_join); pt.width(1.5); /* sprintf(buf, "Num Points=%d Time=%.2fmks\n\n" " Dist Error: x0.01=%.5f x0.1=%.5f x1=%.5f x10=%.5f x100=%.5f\n\n" "Angle Error: x0.01=%.1f x0.1=%.1f x1=%.1f x10=%.1f x100=%.1f", num_points1, curve_time, max_error_01, max_error_1, max_error1, max_error_10, max_error_100, max_angle_error_01, max_angle_error_1, max_angle_error1, max_angle_error_10, max_angle_error_100); */ t.start_point(10.0, 85.0); t.text(buf); ras.add_path(pt); ren.color(rgba(0,0,0)); render_scanlines(ras, sl, ren); render_ctrl(ras, sl, ren_base, m_curve1); render_ctrl(ras, sl, ren_base, m_angle_tolerance); render_ctrl(ras, sl, ren_base, m_approximation_scale); render_ctrl(ras, sl, ren_base, m_cusp_limit); render_ctrl(ras, sl, ren_base, m_width); render_ctrl(ras, sl, ren_base, m_show_points); render_ctrl(ras, sl, ren_base, m_show_outline); render_ctrl(ras, sl, ren_base, m_curve_type); render_ctrl(ras, sl, ren_base, m_case_type); render_ctrl(ras, sl, ren_base, m_inner_join); render_ctrl(ras, sl, ren_base, m_line_join); render_ctrl(ras, sl, ren_base, m_line_cap); }
/* * void draw_curve(Pattern patt, IRasterizer ras, Renderer ren, PatternSource src, IVertexSource vs) * { * patt.create(src); * ren.scale_x(m_scale_x.value()); * ren.start_x(m_start_x.value()); * ras.add_path(vs); * } */ public override void OnDraw() { #if SourceDepth24 FormatRGB pf = new FormatRGB(rbuf_window(), new BlenderBGR()); #else FormatRGBA pf = new FormatRGBA(rbuf_window(), new BlenderBGRA()); #endif FormatClippingProxy ren_base = new FormatClippingProxy(pf); ren_base.clear(new RGBA_Doubles(1.0, 1.0, .95)); rasterizer_scanline_aa ras = new rasterizer_scanline_aa(); scanline_packed_8 sl = new scanline_packed_8(); // Pattern source. Must have an interface: // width() const // height() const // pixel(int x, int y) const // Any agg::renderer_base<> or derived // is good for the use as a source. //----------------------------------- pattern_src_brightness_to_alpha_RGBA_Bytes p1 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(0)); pattern_src_brightness_to_alpha_RGBA_Bytes p2 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(1)); pattern_src_brightness_to_alpha_RGBA_Bytes p3 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(2)); pattern_src_brightness_to_alpha_RGBA_Bytes p4 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(3)); pattern_src_brightness_to_alpha_RGBA_Bytes p5 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(4)); pattern_src_brightness_to_alpha_RGBA_Bytes p6 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(5)); pattern_src_brightness_to_alpha_RGBA_Bytes p7 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(6)); pattern_src_brightness_to_alpha_RGBA_Bytes p8 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(7)); pattern_src_brightness_to_alpha_RGBA_Bytes p9 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(8)); //pattern_filter_bilinear_rgba pattern_filter_bilinear_RGBA_Bytes fltr; // Filtering functor // agg::line_image_pattern is the main container for the patterns. It creates // a copy of the patterns extended according to the needs of the filter. // agg::line_image_pattern can operate with arbitrary image width, but if the // width of the pattern is power of 2, it's better to use the modified // version agg::line_image_pattern_pow2 because it works about 15-25 percent // faster than agg::line_image_pattern (because of using simple masking instead // of expensive '%' operation). //typedef agg::line_image_pattern<agg::pattern_filter_bilinear_RGBA_Bytes> pattern_type; //typedef agg::renderer_base<pixfmt> base_ren_type; //typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_type; //typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; //-- Create with specifying the source //pattern_type patt(fltr, src); //-- Create uninitialized and set the source line_image_pattern patt = new line_image_pattern(new pattern_filter_bilinear_RGBA_Bytes()); //renderer_outline_image ren_img = new renderer_outline_image(, patt); /* * renderer_type ren_img(ren_base, patt); * rasterizer_type ras_img(ren_img); * * draw_curve(patt, ras_img, ren_img, p1, m_curve1.curve()); * draw_curve(patt, ras_img, ren_img, p2, m_curve2.curve()); * draw_curve(patt, ras_img, ren_img, p3, m_curve3.curve()); * draw_curve(patt, ras_img, ren_img, p4, m_curve4.curve()); * draw_curve(patt, ras_img, ren_img, p5, m_curve5.curve()); * draw_curve(patt, ras_img, ren_img, p6, m_curve6.curve()); * draw_curve(patt, ras_img, ren_img, p7, m_curve7.curve()); * draw_curve(patt, ras_img, ren_img, p8, m_curve8.curve()); * draw_curve(patt, ras_img, ren_img, p9, m_curve9.curve()); */ base.OnDraw(); }
public RendererBase(IImage DestImage, rasterizer_scanline_aa Rasterizer) : this() { Initialize(DestImage, Rasterizer); }
/* void draw_curve(Pattern patt, IRasterizer ras, Renderer ren, PatternSource src, IVertexSource vs) { patt.create(src); ren.scale_x(m_scale_x.value()); ren.start_x(m_start_x.value()); ras.add_path(vs); } */ public override void OnDraw() { #if SourceDepth24 FormatRGB pf = new FormatRGB(rbuf_window(), new BlenderBGR()); #else FormatRGBA pf = new FormatRGBA(rbuf_window(), new BlenderBGRA()); #endif FormatClippingProxy ren_base = new FormatClippingProxy(pf); ren_base.clear(new RGBA_Doubles(1.0, 1.0, .95)); rasterizer_scanline_aa ras = new rasterizer_scanline_aa(); scanline_packed_8 sl = new scanline_packed_8(); // Pattern source. Must have an interface: // width() const // height() const // pixel(int x, int y) const // Any agg::renderer_base<> or derived // is good for the use as a source. //----------------------------------- pattern_src_brightness_to_alpha_RGBA_Bytes p1 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(0)); pattern_src_brightness_to_alpha_RGBA_Bytes p2 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(1)); pattern_src_brightness_to_alpha_RGBA_Bytes p3 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(2)); pattern_src_brightness_to_alpha_RGBA_Bytes p4 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(3)); pattern_src_brightness_to_alpha_RGBA_Bytes p5 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(4)); pattern_src_brightness_to_alpha_RGBA_Bytes p6 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(5)); pattern_src_brightness_to_alpha_RGBA_Bytes p7 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(6)); pattern_src_brightness_to_alpha_RGBA_Bytes p8 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(7)); pattern_src_brightness_to_alpha_RGBA_Bytes p9 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img(8)); //pattern_filter_bilinear_rgba pattern_filter_bilinear_RGBA_Bytes fltr; // Filtering functor // agg::line_image_pattern is the main container for the patterns. It creates // a copy of the patterns extended according to the needs of the filter. // agg::line_image_pattern can operate with arbitrary image width, but if the // width of the pattern is power of 2, it's better to use the modified // version agg::line_image_pattern_pow2 because it works about 15-25 percent // faster than agg::line_image_pattern (because of using simple masking instead // of expensive '%' operation). //typedef agg::line_image_pattern<agg::pattern_filter_bilinear_RGBA_Bytes> pattern_type; //typedef agg::renderer_base<pixfmt> base_ren_type; //typedef agg::renderer_outline_image<base_ren_type, pattern_type> renderer_type; //typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type; //-- Create with specifying the source //pattern_type patt(fltr, src); //-- Create uninitialized and set the source line_image_pattern patt = new line_image_pattern(new pattern_filter_bilinear_RGBA_Bytes()); //renderer_outline_image ren_img = new renderer_outline_image(, patt); /* renderer_type ren_img(ren_base, patt); rasterizer_type ras_img(ren_img); draw_curve(patt, ras_img, ren_img, p1, m_curve1.curve()); draw_curve(patt, ras_img, ren_img, p2, m_curve2.curve()); draw_curve(patt, ras_img, ren_img, p3, m_curve3.curve()); draw_curve(patt, ras_img, ren_img, p4, m_curve4.curve()); draw_curve(patt, ras_img, ren_img, p5, m_curve5.curve()); draw_curve(patt, ras_img, ren_img, p6, m_curve6.curve()); draw_curve(patt, ras_img, ren_img, p7, m_curve7.curve()); draw_curve(patt, ras_img, ren_img, p8, m_curve8.curve()); draw_curve(patt, ras_img, ren_img, p9, m_curve9.curve()); */ base.OnDraw(); }
public override void OnDraw(RendererBase renderer) { GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.value()); IBlender NormalBlender = new BlenderBGRA(); IBlender GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterNormal = new ImageBuffer(NewRenderer().DestImage, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(NewRenderer().DestImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new RGBA_Doubles(0,0,0)); rasterizer_scanline_aa ras = new rasterizer_scanline_aa(); scanline_packed_8 sl = new scanline_packed_8(); VertexSource.Ellipse e = new VertexSource.Ellipse(); // TODO: If you drag the control circles below the bottom of the window we get an exception. This does not happen in AGG. // It needs to be debugged. Turning on clipping fixes it. But standard agg works without clipping. Could be a bigger problem than this. //ras.clip_box(0, 0, width(), height()); // Render two "control" circles e.init(m_x[0], m_y[0], 3, 3, 16); ras.add_path(e); Renderer.RenderSolid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127)); e.init(m_x[1], m_y[1], 3, 3, 16); ras.add_path(e); Renderer.RenderSolid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127)); // Creating a rounded rectangle VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0], m_y[0], m_x[1], m_y[1], 10); r.normalize_radius(); // Drawing as an outline conv_stroke p = new conv_stroke(r); p.width(1.0); ras.add_path(p); //Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0)); Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(255, 1, 1)); /* int i; // radial line test //------------------------- dashed_line<rasterizer_type, renderer_scanline_type, scanline_type> dash(ras, ren_sl, sl); double cx = width() / 2.0; double cy = height() / 2.0; ren_sl.color(agg::rgba(1.0, 1.0, 1.0, 0.2)); for(i = 180; i > 0; i--) { double n = 2.0 * agg::pi * i / 180.0; dash.draw(cx + min(cx, cy) * sin(n), cy + min(cx, cy) * cos(n), cx, cy, 1.0, (i < 90) ? i : 0.0); } typedef agg::gradient_x gradient_func_type; typedef agg::span_interpolator_linear<> interpolator_type; typedef agg::span_allocator<color_type> span_allocator_type; typedef agg::pod_auto_array<color_type, 256> color_array_type; typedef agg::span_gradient<color_type, interpolator_type, gradient_func_type, color_array_type> span_gradient_type; typedef agg::renderer_scanline_aa<renderer_base_type, span_allocator_type, span_gradient_type> renderer_gradient_type; gradient_func_type gradient_func; // The gradient function agg::trans_affine gradient_mtx; // Affine transformer interpolator_type span_interpolator(gradient_mtx); // Span interpolator span_allocator_type span_allocator; // Span Allocator color_array_type gradient_colors; // The gradient colors span_gradient_type span_gradient(span_interpolator, gradient_func, gradient_colors, 0, 100); renderer_gradient_type ren_gradient(ren_base, span_allocator, span_gradient); dashed_line<rasterizer_type, renderer_gradient_type, scanline_type> dash_gradient(ras, ren_gradient, sl); double x1, y1, x2, y2; for(i = 1; i <= 20; i++) { ren_sl.color(agg::rgba(1,1,1)); // integral point sizes 1..20 //---------------- agg::ellipse ell; ell.init(20 + i * (i + 1) + 0.5, 20.5, i / 2.0, i / 2.0, 8 + i); ras.reset(); ras.add_path(ell); agg::render_scanlines(ras, sl, ren_sl); // fractional point sizes 0..2 //---------------- ell.init(18 + i * 4 + 0.5, 33 + 0.5, i/20.0, i/20.0, 8); ras.reset(); ras.add_path(ell); agg::render_scanlines(ras, sl, ren_sl); // fractional point positioning //--------------- ell.init(18 + i * 4 + (i-1) / 10.0 + 0.5, 27 + (i - 1) / 10.0 + 0.5, 0.5, 0.5, 8); ras.reset(); ras.add_path(ell); agg::render_scanlines(ras, sl, ren_sl); // integral line widths 1..20 //---------------- fill_color_array(gradient_colors, agg::rgba(1,1,1), agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25)); x1 = 20 + i* (i + 1); y1 = 40.5; x2 = 20 + i * (i + 1) + (i - 1) * 4; y2 = 100.5; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, i, 0); fill_color_array(gradient_colors, agg::rgba(1,0,0), agg::rgba(0,0,1)); // fractional line lengths H (red/blue) //---------------- x1 = 17.5 + i * 4; y1 = 107; x2 = 17.5 + i * 4 + i/6.66666667; y2 = 107; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, 1.0, 0); // fractional line lengths V (red/blue) //--------------- x1 = 18 + i * 4; y1 = 112.5; x2 = 18 + i * 4; y2 = 112.5 + i / 6.66666667; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, 1.0, 0); // fractional line positioning (red) //--------------- fill_color_array(gradient_colors, agg::rgba(1,0,0), agg::rgba(1,1,1)); x1 = 21.5; y1 = 120 + (i - 1) * 3.1; x2 = 52.5; y2 = 120 + (i - 1) * 3.1; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, 1.0, 0); // fractional line width 2..0 (green) fill_color_array(gradient_colors, agg::rgba(0,1,0), agg::rgba(1,1,1)); x1 = 52.5; y1 = 118 + i * 3; x2 = 83.5; y2 = 118 + i * 3; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 0); // stippled fractional width 2..0 (blue) fill_color_array(gradient_colors, agg::rgba(0,0,1), agg::rgba(1,1,1)); x1 = 83.5; y1 = 119 + i * 3; x2 = 114.5; y2 = 119 + i * 3; calc_linear_gradient_transform(x1, y1, x2, y2, gradient_mtx); dash_gradient.draw(x1, y1, x2, y2, 2.0 - (i - 1) / 10.0, 3.0); ren_sl.color(agg::rgba(1,1,1)); if(i <= 10) { // integral line width, horz aligned (mipmap test) //------------------- dash.draw(125.5, 119.5 + (i + 2) * (i / 2.0), 135.5, 119.5 + (i + 2) * (i / 2.0), i, 0.0); } // fractional line width 0..2, 1 px H //----------------- dash.draw(17.5 + i * 4, 192, 18.5 + i * 4, 192, i / 10.0, 0); // fractional line positioning, 1 px H //----------------- dash.draw(17.5 + i * 4 + (i - 1) / 10.0, 186, 18.5 + i * 4 + (i - 1) / 10.0, 186, 1.0, 0); } // Triangles //--------------- for (int i = 1; i <= 13; i++) { fill_color_array(gradient_colors, agg::rgba(1,1,1), agg::rgba(i % 2, (i % 3) * 0.5, (i % 5) * 0.25)); calc_linear_gradient_transform(width() - 150, height() - 20 - i * (i + 1.5), width() - 20, height() - 20 - i * (i + 1), gradient_mtx); ras.reset(); ras.move_to_d(width() - 150, height() - 20 - i * (i + 1.5)); ras.line_to_d(width() - 20, height() - 20 - i * (i + 1)); ras.line_to_d(width() - 20, height() - 20 - i * (i + 2)); agg::render_scanlines(ras, sl, ren_gradient); } */ base.OnDraw(renderer); }
void DrawImage(IImage sourceImage, double DestX, double DestY, double HotspotOffsetX, double HotspotOffsetY, double ScaleX, double ScaleY, double AngleRad, RGBA_Bytes Color32, ref RectangleD pFinalBlitBounds, bool doDrawing, bool oneMinusSourceAlphaOne) { Affine destRectTransform = Affine.NewIdentity(); if (HotspotOffsetX != 0.0f || HotspotOffsetY != 0.0f) { destRectTransform *= Affine.NewTranslation(-HotspotOffsetX, -HotspotOffsetY); } if (ScaleX != 1 || ScaleY != 1) { destRectTransform *= Affine.NewScaling(ScaleX, ScaleY); } if (AngleRad != 0) { destRectTransform *= Affine.NewRotation(AngleRad); } if (DestX != 0 || DestY != 0) { destRectTransform *= Affine.NewTranslation(DestX, DestY); } int SourceBufferWidth = (int)sourceImage.Width(); int SourceBufferHeight = (int)sourceImage.Height(); RectPath.Clear(); RectPath.MoveTo(0, 0); RectPath.LineTo(SourceBufferWidth, 0); RectPath.LineTo(SourceBufferWidth, SourceBufferHeight); RectPath.LineTo(0, SourceBufferHeight); RectPath.ClosePolygon(); // Calculate the bounds. LBB [10/5/2004] const int ERROR_ADD = 0; double BoundXDouble, BoundYDouble; BoundXDouble = 0; BoundYDouble = 0; destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble); double BoundX = (double)BoundXDouble; double BoundY = (double)BoundYDouble; pFinalBlitBounds.Left = Math.Floor(BoundX - ERROR_ADD); pFinalBlitBounds.Right = Math.Ceiling(BoundX + ERROR_ADD); pFinalBlitBounds.Top = Math.Floor(BoundY - ERROR_ADD); pFinalBlitBounds.Bottom = Math.Ceiling(BoundY + ERROR_ADD); BoundXDouble = SourceBufferWidth; BoundYDouble = 0; destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble); BoundX = (double)BoundXDouble; BoundY = (double)BoundYDouble; pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left); pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right); pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top); pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom); BoundXDouble = SourceBufferWidth; BoundYDouble = SourceBufferHeight; destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble); BoundX = (double)BoundXDouble; BoundY = (double)BoundYDouble; pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left); pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right); pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top); pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom); BoundXDouble = 0; BoundYDouble = SourceBufferHeight; destRectTransform.Transform(ref BoundXDouble, ref BoundYDouble); BoundX = (double)BoundXDouble; BoundY = (double)BoundYDouble; pFinalBlitBounds.Left = Math.Min((long)Math.Floor(BoundX - ERROR_ADD), pFinalBlitBounds.Left); pFinalBlitBounds.Right = Math.Max((long)Math.Ceiling(BoundX + ERROR_ADD), pFinalBlitBounds.Right); pFinalBlitBounds.Top = Math.Min((long)Math.Floor(BoundY - ERROR_ADD), pFinalBlitBounds.Top); pFinalBlitBounds.Bottom = Math.Max((long)Math.Ceiling(BoundY + ERROR_ADD), pFinalBlitBounds.Bottom); if (!doDrawing) { return; } if (m_DestImage.OriginOffset.x != 0 || m_DestImage.OriginOffset.y != 0) { destRectTransform *= Affine.NewTranslation(-m_DestImage.OriginOffset.x, -m_DestImage.OriginOffset.y); } Affine sourceRectTransform = new Affine(destRectTransform); // We invert it because it is the transform to make the image go to the same position as the polygon. LBB [2/24/2004] sourceRectTransform.Invert(); span_allocator spanAllocator = new span_allocator(); span_interpolator_linear interpolator = new span_interpolator_linear(sourceRectTransform); ImageBuffer sourceImageWithBlender = (ImageBuffer)sourceImage;// new ImageBuffer(sourceImage, new BlenderBGRA()); span_image_filter_rgba_bilinear_clip spanImageFilter; ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImageWithBlender, RGBA_Doubles.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); spanImageFilter = new span_image_filter_rgba_bilinear_clip(source, RGBA_Doubles.rgba_pre(0, 0, 0, 0), interpolator); rasterizer_scanline_aa rasterizer = new rasterizer_scanline_aa(); rasterizer.SetVectorClipBox(0, 0, m_DestImage.Width(), m_DestImage.Height()); scanline_packed_8 scanlineCache = new scanline_packed_8(); //scanline_unpacked_8 scanlineCache = new scanline_unpacked_8(); conv_transform transfromedRect = new conv_transform(RectPath, destRectTransform); rasterizer.add_path(transfromedRect); #if false bool HighQualityFilter = (BlitXParams.m_OptionalFlags & CBlitXParams::BlitHighQualityFilter) != 0 && (BlitXParams.m_OptionalFlags & CBlitXParams::RenderOneMinusScrAlpha_One) == 0; if (HighQualityFilter) {
public Renderer(IImage destImage, rasterizer_scanline_aa rasterizer, IScanlineCache scanlineCache) : base(destImage, rasterizer) { m_ScanlineCache = scanlineCache; }