public override void OnDraw(Graphics2D graphics2D) { ImageClippingProxy ren_base = new ImageClippingProxy(graphics2D.DestImage); ren_base.clear(new RGBA_Floats(1.0, 1.0, .95)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); // 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_img0); pattern_src_brightness_to_alpha_RGBA_Bytes p2 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img1); pattern_src_brightness_to_alpha_RGBA_Bytes p3 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img2); pattern_src_brightness_to_alpha_RGBA_Bytes p4 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img3); pattern_src_brightness_to_alpha_RGBA_Bytes p5 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img4); pattern_src_brightness_to_alpha_RGBA_Bytes p6 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img5); pattern_src_brightness_to_alpha_RGBA_Bytes p7 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img6); pattern_src_brightness_to_alpha_RGBA_Bytes p8 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img7); pattern_src_brightness_to_alpha_RGBA_Bytes p9 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img8); //pattern_filter_bilinear_RGBA_Bytes fltr = new pattern_filter_bilinear_RGBA_Bytes(); // 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). //-- Create with specifying the source //-- Create uninitialized and set the source line_image_pattern patt = new line_image_pattern(new pattern_filter_bilinear_RGBA_Bytes()); ImageLineRenderer ren_img = new ImageLineRenderer(ren_base, patt); rasterizer_outline_aa ras_img = new rasterizer_outline_aa(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(graphics2D); }
public image_resample() { m_gamma_lut = new GammaLookUpTable(2.0); m_quad = new MatterHackers.Agg.UI.PolygonEditWidget(4, 5.0); m_trans_type = new MatterHackers.Agg.UI.RadioButtonGroup(new Vector2(400, 5.0), new Vector2(30 + 170.0, 95)); m_gamma = new MatterHackers.Agg.UI.Slider(5.0, 5.0 + 15 * 0, 400 - 5, 10.0 + 15 * 0); m_blur = new MatterHackers.Agg.UI.Slider(5.0, 5.0 + 15 * 1, 400 - 5, 10.0 + 15 * 1); m_blur.ValueChanged += new EventHandler(NeedRedraw); m_gamma.ValueChanged += new EventHandler(NeedRedraw); m_old_gamma = 2.0; g_rasterizer = new ScanlineRasterizer(); g_scanline = new scanline_unpacked_8(); m_trans_type.AddRadioButton("Affine No Resample"); m_trans_type.AddRadioButton("Affine Resample"); m_trans_type.AddRadioButton("Perspective No Resample LERP"); m_trans_type.AddRadioButton("Perspective No Resample Exact"); m_trans_type.AddRadioButton("Perspective Resample LERP"); m_trans_type.AddRadioButton("Perspective Resample Exact"); m_trans_type.SelectedIndex = 4; AddChild(m_trans_type); m_gamma.SetRange(0.5, 3.0); m_gamma.Value = 2.0; m_gamma.Text = "Gamma={0:F3}"; AddChild(m_gamma); m_blur.SetRange(0.5, 5.0); m_blur.Value = 1.0; m_blur.Text = "Blur={0:F3}"; AddChild(m_blur); }
public static ImageBuffer TrasparentToColorGradientX(int width, int height, Color color, int distance) { var innerGradient = new gradient_x(); var outerGradient = new gradient_clamp_adaptor(innerGradient); // gradient_repeat_adaptor/gradient_reflect_adaptor/gradient_clamp_adaptor var rect = new RoundedRect(new RectangleDouble(0, 0, width, height), 0); var ras = new ScanlineRasterizer(); ras.add_path(rect); var imageBuffer = new ImageBuffer(width, height); imageBuffer.SetRecieveBlender(new BlenderPreMultBGRA()); var scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.GenerateAndRender( ras, new scanline_unpacked_8(), imageBuffer, new span_allocator(), new span_gradient( new span_interpolator_linear(Affine.NewIdentity()), outerGradient, new GradientColors(Enumerable.Range(0, 256).Select(i => new Color(color, i))), // steps from full transparency color to solid color 0, distance)); return(imageBuffer); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; #if SourceDepth24 pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(backBuffer, new blender_bgr()); #else ImageBuffer pf = new ImageBuffer(); pf.Attach(backBuffer, new BlenderBGRA()); #endif ImageClippingProxy ren_base = new ImageClippingProxy(pf); ren_base.clear(new RGBA_Floats(1.0, 1.0, 1.0)); scanline_unpacked_8 sl = new scanline_unpacked_8(); ScanlineRasterizer ras = new ScanlineRasterizer(); #if true render_gouraud(backBuffer, sl, ras); #else agg.span_allocator span_alloc = new span_allocator(); span_gouraud_rgba span_gen = new span_gouraud_rgba(new rgba8(255, 0, 0, 255), new rgba8(0, 255, 0, 255), new rgba8(0, 0, 255, 255), 320, 220, 100, 100, 200, 100, 0); span_gouraud test_sg = new span_gouraud(new rgba8(0, 0, 0, 255), new rgba8(0, 0, 0, 255), new rgba8(0, 0, 0, 255), 320, 220, 100, 100, 200, 100, 0); ras.add_path(test_sg); renderer_scanlines.render_scanlines_aa(ras, sl, ren_base, span_alloc, span_gen); //renderer_scanlines.render_scanlines_aa_solid(ras, sl, ren_base, new rgba8(0, 0, 0, 255)); #endif ras.gamma(new gamma_none()); //m_dilation.Render(ras, sl, ren_base); //m_gamma.Render(ras, sl, ren_base); //m_alpha.Render(ras, sl, ren_base); base.OnDraw(graphics2D); }
internal InternalImageGraphics2D(ImageBuffer owner) : base() { ScanlineRasterizer rasterizer = new ScanlineRasterizer(); ImageClippingProxy imageClippingProxy = new ImageClippingProxy(owner); Initialize(imageClippingProxy, rasterizer); ScanlineCache = new ScanlineCachePacked8(); }
public void draw(ScanlineRasterizer ras, IScanlineCache sl, IImageByte destImage, RGBA_Bytes color, double x, double y) { ras.reset(); ras.move_to_d(x * m_size, y * m_size); ras.line_to_d(x * m_size + m_size, y * m_size); ras.line_to_d(x * m_size + m_size, y * m_size + m_size); ras.line_to_d(x * m_size, y * m_size + m_size); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(destImage, ras, sl, color); }
public void draw(ScanlineRasterizer ras, IScanlineCache sl, IImageByte destImage, RGBA_Bytes color, double x, double y) { ras.reset(); ras.move_to_d(x * m_size, y * m_size); ras.line_to_d(x * m_size + m_size, y * m_size); ras.line_to_d(x * m_size + m_size, y * m_size + m_size); ras.line_to_d(x * m_size, y * m_size + m_size); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.render_scanlines_aa_solid(destImage, ras, sl, color); }
public override void OnMouseDown(MouseEventArgs mouseEvent) { int i; if (mouseEvent.Button == MouseButtons.Right) { scanline_unpacked_8 sl = new scanline_unpacked_8(); ScanlineRasterizer ras = new ScanlineRasterizer(); stopwatch.Restart(); for (i = 0; i < 100; i++) { //render_gouraud(sl, ras); } stopwatch.Stop(); string buf; buf = "Time=" + stopwatch.ElapsedMilliseconds.ToString() + "ms"; throw new NotImplementedException(); //guiSurface.ShowSystemMessage(buf); } if (mouseEvent.Button == MouseButtons.Left) { double x = mouseEvent.X; double y = mouseEvent.Y; for (i = 0; i < 3; i++) { if (Math.Sqrt((x - m_x[i]) * (x - m_x[i]) + (y - m_y[i]) * (y - m_y[i])) < 10.0) { m_dx = x - m_x[i]; m_dy = y - m_y[i]; m_idx = (int)i; break; } } if (i == 3) { if (agg_math.point_in_triangle(m_x[0], m_y[0], m_x[1], m_y[1], m_x[2], m_y[2], x, y)) { m_dx = x - m_x[0]; m_dy = y - m_y[0]; m_idx = 3; } } } base.OnMouseDown(mouseEvent); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); GammaLookUpTable gamma = new GammaLookUpTable(gammaSlider.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterGamma = new ImageBuffer(); rasterGamma.Attach(widgetsSubImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(widgetsSubImage); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new ColorF(1, 1, 1)); ScanlineRasterizer rasterizer = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); int size_mul = (int)pixelSizeSlider.Value; renderer_enlarged ren_en = new renderer_enlarged(size_mul); rasterizer.reset(); rasterizer.move_to_d(m_x[0] / size_mul, m_y[0] / size_mul); rasterizer.line_to_d(m_x[1] / size_mul, m_y[1] / size_mul); rasterizer.line_to_d(m_x[2] / size_mul, m_y[2] / size_mul); ren_en.RenderSolid(clippingProxyGamma, rasterizer, sl, Color.Black); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyGamma, rasterizer, sl, Color.Black); rasterizer.gamma(new gamma_none()); VertexStorage ps = new VertexStorage(); Stroke pg = new Stroke(ps); pg.Width = 2; ps.remove_all(); ps.MoveTo(m_x[0], m_y[0]); ps.LineTo(m_x[1], m_y[1]); ps.LineTo(m_x[2], m_y[2]); ps.LineTo(m_x[0], m_y[0]); rasterizer.add_path(pg); scanlineRenderer.RenderSolid(clippingProxyNormal, rasterizer, sl, new Color(0, 150, 160, 200)); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { GammaLookUpTable gamma = new GammaLookUpTable(gammaSlider.Value); IRecieveBlenderByte NormalBlender = new BlenderBGR(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGR(gamma); ImageBuffer rasterNormal = new ImageBuffer(); rasterNormal.Attach(graphics2D.DestImage, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(); rasterGamma.Attach(graphics2D.DestImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new RGBA_Floats(1, 1, 1)); ScanlineRasterizer ras = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); int size_mul = (int)pixelSizeSlider.Value; renderer_enlarged ren_en = new renderer_enlarged(size_mul); StyledTypeFace type = new StyledTypeFace(LiberationSansFont.Instance, 12); IVertexSource character = type.GetGlyphForCharacter('E'); character.rewind(0); ras.reset(); ras.add_path(character); ren_en.RenderSolid(clippingProxyGamma, ras, sl, RGBA_Bytes.Black); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyGamma, ras, sl, RGBA_Bytes.Black); ras.gamma(new gamma_none()); PathStorage ps = new PathStorage(); Stroke pg = new Stroke(ps); pg.width(2); DrawBigA(graphics2D); base.OnDraw(graphics2D); }
private void DrawBigA(Graphics2D graphics2D) { ScanlineRasterizer m_ras = new ScanlineRasterizer(); m_ras.SetVectorClipBox(0, 0, Width, Height); TypeFacePrinter bigAPrinter = new TypeFacePrinter("a", 150); FlattenCurves flattenedBigA = new FlattenCurves(bigAPrinter); VertexSourceApplyTransform scaleAndTranslate = new VertexSourceApplyTransform(flattenedBigA, Affine.NewTranslation(155, 55)); ScanlineCachePacked8 m_sl = new ScanlineCachePacked8(); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); #if false ImageProxySubpxelLcd24 clippingProxy = new ImageProxySubpxelLcd24(graphics2D.DestImage, new lcd_distribution_lut()); VertexSourceApplyTransform scaledWide = new VertexSourceApplyTransform(scaleAndTranslate, Affine.NewScaling(3, 1)); m_ras.add_path(scaledWide); scanlineRenderer.render_scanlines_aa_solid(clippingProxy, m_ras, m_sl, RGBA_Bytes.Black); #else m_ras.add_path(scaleAndTranslate); ImageClippingProxy clippingProxy = new ImageClippingProxy(graphics2D.DestImage); scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, RGBA_Bytes.Black); #endif }
public override void OnDraw(Graphics2D graphics2D) { if (graphics2D.DestImage != null) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; int distBetween = backBuffer.GetBytesBetweenPixelsInclusive(); ImageBuffer redImageBuffer = new ImageBuffer(); redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8); ImageBuffer greenImageBuffer = new ImageBuffer(); greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8); ImageBuffer blueImageBuffer = new ImageBuffer(); blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8); ImageClippingProxy clippingProxy = new ImageClippingProxy(backBuffer); ImageClippingProxy clippingProxyRed = new ImageClippingProxy(redImageBuffer); ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer); ImageClippingProxy clippingProxyBlue = new ImageClippingProxy(blueImageBuffer); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); RGBA_Bytes clearColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(0, 0, 0) : new RGBA_Bytes(255, 255, 255); clippingProxy.clear(clearColor); alphaSlider.View.BackgroundColor = clearColor; RGBA_Bytes FillColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(255, 255, 255, (int)(alphaSlider.Value)) : new RGBA_Bytes(0, 0, 0, (int)(alphaSlider.Value)); VertexSource.Ellipse er = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100); ras.add_path(er); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyRed, ras, sl, FillColor); VertexSource.Ellipse eg = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100); ras.add_path(eg); scanlineRenderer.RenderSolid(clippingProxyGreen, ras, sl, FillColor); VertexSource.Ellipse eb = new MatterHackers.Agg.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100); ras.add_path(eb); scanlineRenderer.RenderSolid(clippingProxyBlue, ras, sl, FillColor); } else if (graphics2D.DestImageFloat != null) { #if false IImageFloat backBuffer = graphics2D.DestImageFloat; int distBetween = backBuffer.GetFloatsBetweenPixelsInclusive(); ImageBufferFloat redImageBuffer = new ImageBufferFloat(); redImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 2, 8); ImageBufferFloat greenImageBuffer = new ImageBufferFloat(); greenImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 1, 8); ImageBufferFloat blueImageBuffer = new ImageBufferFloat(); blueImageBuffer.Attach(backBuffer, new blender_gray(distBetween), distBetween, 0, 8); ImageClippingProxy clippingProxy = new ImageClippingProxy(backBuffer); ImageClippingProxy clippingProxyRed = new ImageClippingProxy(redImageBuffer); ImageClippingProxy clippingProxyGreen = new ImageClippingProxy(greenImageBuffer); ImageClippingProxy clippingProxyBlue = new ImageClippingProxy(blueImageBuffer); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); RGBA_Bytes clearColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(0, 0, 0) : new RGBA_Bytes(255, 255, 255); clippingProxy.clear(clearColor); alphaSlider.View.BackGroundColor = clearColor; RGBA_Bytes FillColor = useBlackBackgroundCheckbox.Checked ? new RGBA_Bytes(255, 255, 255, (int)(alphaSlider.Value)) : new RGBA_Bytes(0, 0, 0, (int)(alphaSlider.Value)); VertexSource.Ellipse er = new AGG.VertexSource.Ellipse(Width / 2 - 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100); ras.add_path(er); agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyRed, ras, sl, FillColor); VertexSource.Ellipse eg = new AGG.VertexSource.Ellipse(Width / 2 + 0.87 * 50, Height / 2 - 0.5 * 50, 100, 100, 100); ras.add_path(eg); agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyGreen, ras, sl, FillColor); VertexSource.Ellipse eb = new AGG.VertexSource.Ellipse(Width / 2, Height / 2 + 50, 100, 100, 100); ras.add_path(eb); agg_renderer_scanline.Default.render_scanlines_aa_solid(clippingProxyBlue, ras, sl, FillColor); #endif } base.OnDraw(graphics2D); }
public ImageGraphics2D(IImageByte destImage, ScanlineRasterizer rasterizer, IScanlineCache scanlineCache) : base(destImage, rasterizer) { this.scanlineCache = scanlineCache; }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; IImageByte destImage = backBuffer; ImageClippingProxy clippingProxy = new ImageClippingProxy(destImage); clippingProxy.clear(new RGBA_Floats(0, 0, 0)); ScanlineRasterizer ras = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); scanline_bin sl_bin = new scanline_bin(); rasterizer_compound_aa rasc = new rasterizer_compound_aa(); span_allocator alloc = new span_allocator(); int i; styles_gouraud styles = new styles_gouraud(m_mesh, m_gamma); stopwatch.Restart(); rasc.reset(); //rasc.clip_box(40, 40, width() - 40, height() - 40); for (i = 0; i < m_mesh.num_edges(); i++) { mesh_edge e = m_mesh.edge(i); mesh_point p1 = m_mesh.vertex(e.p1); mesh_point p2 = m_mesh.vertex(e.p2); rasc.styles(e.tl, e.tr); rasc.move_to_d(p1.x, p1.y); rasc.line_to_d(p2.x, p2.y); } ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderCompound(rasc, sl, sl_bin, clippingProxy, alloc, styles); double tm = stopwatch.ElapsedMilliseconds; gsv_text t = new gsv_text(); t.SetFontSize(10.0); Stroke pt = new Stroke(t); pt.width(1.5); pt.line_cap(LineCap.Round); pt.line_join(LineJoin.Round); string buf = string.Format("{0:F2} ms, {1} triangles, {2:F0} tri/sec", tm, m_mesh.num_triangles(), m_mesh.num_triangles() / tm * 1000.0); t.start_point(10.0, 10.0); t.text(buf); ras.add_path(pt); scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(255, 255, 255)); if (m_gamma.GetGamma() != 1.0) { ((ImageBuffer)destImage).apply_gamma_inv(m_gamma); } base.OnDraw(graphics2D); }
public ImageGraphics2D(IImageByte destImage, ScanlineRasterizer rasterizer, IScanlineCache scanlineCache) : base(destImage, rasterizer) { m_ScanlineCache = scanlineCache; }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); ScanlineRasterizer ras = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage); clippingProxy.clear(new RGBA_Floats(0, 0, 0)); m_profile.text_size(8.0); // draw a background to show how the alpha is working int RectWidth = 32; int xoffset = 238; int yoffset = 171; ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if ((i + j) % 2 != 0) { VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset, (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2); rect.normalize_radius(); ras.add_path(rect); scanlineRenderer.render_scanlines_aa_solid(clippingProxy, ras, sl, new RGBA_Bytes(.9, .9, .9)); } } } double ini_scale = 1.0; Transform.Affine mtx1 = Affine.NewIdentity(); mtx1 *= Affine.NewScaling(ini_scale, ini_scale); mtx1 *= Affine.NewTranslation(center_x, center_y); VertexSource.Ellipse e1 = new MatterHackers.Agg.VertexSource.Ellipse(); e1.init(0.0, 0.0, 110.0, 110.0, 64); Transform.Affine mtx_g1 = Affine.NewIdentity(); mtx_g1 *= Affine.NewScaling(ini_scale, ini_scale); mtx_g1 *= Affine.NewScaling(m_SaveData.m_scale, m_SaveData.m_scale); mtx_g1 *= Affine.NewScaling(m_scale_x, m_scale_y); mtx_g1 *= Affine.NewRotation(m_SaveData.m_angle); mtx_g1 *= Affine.NewTranslation(m_SaveData.m_center_x, m_SaveData.m_center_y); mtx_g1.invert(); RGBA_Bytes[] color_profile = new RGBA_Bytes[256]; // color_type is defined in pixel_formats.h for (int i = 0; i < 256; i++) { color_profile[i] = new RGBA_Bytes(m_spline_r.spline()[i], m_spline_g.spline()[i], m_spline_b.spline()[i], m_spline_a.spline()[i]); } VertexSourceApplyTransform t1 = new VertexSourceApplyTransform(e1, mtx1); IGradient innerGradient = null; switch (m_GradTypeRBox.SelectedIndex) { case 0: innerGradient = new gradient_radial(); break; case 1: innerGradient = new gradient_diamond(); break; case 2: innerGradient = new gradient_x(); break; case 3: innerGradient = new gradient_xy(); break; case 4: innerGradient = new gradient_sqrt_xy(); break; case 5: innerGradient = new gradient_conic(); break; } IGradient outerGradient = null; switch (m_GradWrapRBox.SelectedIndex) { case 0: outerGradient = new gradient_reflect_adaptor(innerGradient); break; case 1: outerGradient = new gradient_repeat_adaptor(innerGradient); break; case 2: outerGradient = new gradient_clamp_adaptor(innerGradient); break; } span_allocator span_alloc = new span_allocator(); color_function_profile colors = new color_function_profile(color_profile, m_profile.gamma()); span_interpolator_linear inter = new span_interpolator_linear(mtx_g1); span_gradient span_gen = new span_gradient(inter, outerGradient, colors, 0, 150); ras.add_path(t1); scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy, span_alloc, span_gen); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); GammaLookUpTable gamma = new GammaLookUpTable(gammaSlider.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterGamma = new ImageBuffer(); rasterGamma.Attach(widgetsSubImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(widgetsSubImage); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new RGBA_Floats(1, 1, 1)); ScanlineRasterizer rasterizer = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); int size_mul = (int)pixelSizeSlider.Value; renderer_enlarged ren_en = new renderer_enlarged(size_mul); rasterizer.reset(); rasterizer.move_to_d(m_x[0] / size_mul, m_y[0] / size_mul); rasterizer.line_to_d(m_x[1] / size_mul, m_y[1] / size_mul); rasterizer.line_to_d(m_x[2] / size_mul, m_y[2] / size_mul); ren_en.RenderSolid(clippingProxyGamma, rasterizer, sl, RGBA_Bytes.Black); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyGamma, rasterizer, sl, RGBA_Bytes.Black); rasterizer.gamma(new gamma_none()); PathStorage ps = new PathStorage(); Stroke pg = new Stroke(ps); pg.width(2); ps.remove_all(); ps.MoveTo(m_x[0], m_y[0]); ps.LineTo(m_x[1], m_y[1]); ps.LineTo(m_x[2], m_y[2]); ps.LineTo(m_x[0], m_y[0]); rasterizer.add_path(pg); scanlineRenderer.RenderSolid(clippingProxyNormal, rasterizer, sl, new RGBA_Bytes(0, 150, 160, 200)); base.OnDraw(graphics2D); }
public void Initialize(IImageFloat destImage, ScanlineRasterizer rasterizer) { destImageByte = null; destImageFloat = destImage; this.rasterizer = rasterizer; }
public image_filters() : base(FlowDirection.BottomToTop) { m_step = new Slider(new Vector2(115, 5), new Vector2(285, 6)); m_radius = new Slider(new Vector2(115, 5 + 15), new Vector2(285, 6)); filterSelectionButtons = new RadioButtonGroup(new Vector2(0.0, 10.0), new Vector2(110.0, 210.0)); m_normalize = new CheckBox(8.0, 215.0, "Normalize Filter"); m_refresh = new Button(8.0, 273.0, new ButtonViewText("Refresh", 8, 1, 3)); m_refresh.Click += RefreshImage; m_run = new Button(8.0, 253.0, new ButtonViewText("RUN Test!", 8, 1, 3)); m_run.Click += RunTest; m_single_step = new Button(8.0, 233.0, new ButtonViewText("Single Step", 8, 1, 3)); m_single_step.Click += SingleStep; m_cur_angle = (0.0); m_cur_filter = (1); m_num_steps = (0); m_num_pix = (0.0); m_time1 = (0); m_time2 = (0); m_ScanlinePacked = new ScanlineCachePacked8(); m_Rasterizer = new ScanlineRasterizer(); m_ScanlineUnpacked = new scanline_unpacked_8(); m_SpanAllocator = new span_allocator(); AddChild(m_radius); AddChild(m_step); AddChild(filterSelectionButtons); AddChild(m_run); AddChild(m_single_step); AddChild(m_normalize); AddChild(m_refresh); m_normalize.Checked = true; m_radius.Text = "Filter Radius={0:F2}"; m_step.Text = "Step={0:F2}"; m_radius.SetRange(2.0, 8.0); m_radius.Value = 4.0; m_step.SetRange(1.0, 10.0); m_step.Value = 5.0; filterSelectionButtons.AddRadioButton("simple (NN)"); filterSelectionButtons.AddRadioButton("bilinear"); filterSelectionButtons.AddRadioButton("bicubic"); filterSelectionButtons.AddRadioButton("spline16"); filterSelectionButtons.AddRadioButton("spline36"); filterSelectionButtons.AddRadioButton("hanning"); filterSelectionButtons.AddRadioButton("hamming"); filterSelectionButtons.AddRadioButton("hermite"); filterSelectionButtons.AddRadioButton("kaiser"); filterSelectionButtons.AddRadioButton("quadric"); filterSelectionButtons.AddRadioButton("catrom"); filterSelectionButtons.AddRadioButton("gaussian"); filterSelectionButtons.AddRadioButton("bessel"); filterSelectionButtons.AddRadioButton("mitchell"); filterSelectionButtons.AddRadioButton("sinc"); filterSelectionButtons.AddRadioButton("lanczos"); filterSelectionButtons.AddRadioButton("blackman"); filterSelectionButtons.SelectedIndex = 1; filterSelectionButtons.background_color(new ColorF(0.0, 0.0, 0.0, 0.1)); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterNormal = new ImageBuffer(); rasterNormal.Attach(backBuffer, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(); rasterGamma.Attach(backBuffer, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(m_white_on_black.Checked ? new RGBA_Floats(0, 0, 0) : new RGBA_Floats(1, 1, 1)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); 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); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127)); e.init(m_x[1], m_y[1], 3, 3, 16); ras.add_path(e); scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127)); double d = m_offset.Value; // Creating a rounded rectangle VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, m_radius.Value); r.normalize_radius(); // Drawing as an outline if (!m_DrawAsOutlineCheckBox.Checked) { Stroke p = new Stroke(r); p.width(1.0); ras.add_path(p); } else { ras.add_path(r); } scanlineRenderer.render_scanlines_aa_solid(clippingProxyGamma, ras, sl, m_white_on_black.Checked ? new RGBA_Bytes(255, 255, 255) : new RGBA_Bytes(0, 0, 0)); base.OnDraw(graphics2D); }
public Graphics2D(IImageByte destImage, ScanlineRasterizer rasterizer) : this() { Initialize(destImage, rasterizer); }
public override void OnDraw(Graphics2D graphics2D) { GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterNormal = new ImageBuffer(NewGraphics2D().DestImage, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(NewGraphics2D().DestImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new RGBA_Floats(0, 0, 0)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); 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); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.render_scanlines_aa_solid(clippingProxyNormal, ras, sl, new RGBA_Bytes(127, 127, 127)); e.init(m_x[1], m_y[1], 3, 3, 16); ras.add_path(e); scanlineRenderer.render_scanlines_aa_solid(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 Stroke p = new Stroke(r); p.width(1.0); ras.add_path(p); //Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0)); scanlineRenderer.render_scanlines_aa_solid(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(graphics2D); }
public void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, RGBA_Bytes partColorIn, double minZ, double maxZ) { RGBA_Floats partColor = partColorIn.GetAsRGBA_Floats(); graphics2D.Rasterizer.gamma(new gamma_power(.3)); RenderPoint[] points = new RenderPoint[3] { new RenderPoint(), new RenderPoint(), new RenderPoint() }; foreach (Face face in meshToDraw.Faces) { int i = 0; Vector3 normal = Vector3.TransformVector(face.normal, trackballTumbleWidget.ModelviewMatrix).GetNormal(); if (normal.z > 0) { foreach (FaceEdge faceEdge in face.FaceEdges()) { points[i].position = trackballTumbleWidget.GetScreenPosition(faceEdge.firstVertex.Position); Vector3 transformedPosition = Vector3.TransformPosition(faceEdge.firstVertex.Position, trackballTumbleWidget.ModelviewMatrix); points[i].z = transformedPosition.z; i++; } RGBA_Floats polyDrawColor = new RGBA_Floats(); double L = Vector3.Dot(lightNormal, normal); if (L > 0.0f) { polyDrawColor = partColor * lightIllumination * L; } polyDrawColor = RGBA_Floats.ComponentMax(polyDrawColor, partColor * ambiantIllumination); for (i = 0; i < 3; i++) { double ratio = (points[i].z - minZ) / (maxZ - minZ); int ratioInt16 = (int)(ratio * 65536); points[i].color = new RGBA_Bytes(polyDrawColor.Red0To255, ratioInt16 >> 8, ratioInt16 & 0xFF); } #if true scanline_unpacked_8 sl = new scanline_unpacked_8(); ScanlineRasterizer ras = new ScanlineRasterizer(); render_gouraud(graphics2D.DestImage, sl, ras, points); #else IRecieveBlenderByte oldBlender = graphics2D.DestImage.GetRecieveBlender(); graphics2D.DestImage.SetRecieveBlender(new BlenderZBuffer()); graphics2D.Render(polygonProjected, renderColor); graphics2D.DestImage.SetRecieveBlender(oldBlender); #endif byte[] buffer = graphics2D.DestImage.GetBuffer(); int pixels = graphics2D.DestImage.Width * graphics2D.DestImage.Height; for (int pixelIndex = 0; pixelIndex < pixels; pixelIndex++) { buffer[pixelIndex * 4 + ImageBuffer.OrderR] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; buffer[pixelIndex * 4 + ImageBuffer.OrderG] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; buffer[pixelIndex * 4 + ImageBuffer.OrderB] = buffer[pixelIndex * 4 + ImageBuffer.OrderR]; } } } }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); if (orignialSize.x == 0) { orignialSize.x = WindowSize.x; orignialSize.y = WindowSize.y; } ImageBuffer destImageWithPreMultBlender = new ImageBuffer(); switch (widgetsSubImage.BitDepth) { case 24: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGR()); break; case 32: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGRA()); break; default: throw new Exception("Unknown bit depth"); } ImageClippingProxy clippingProxy_pre = new ImageClippingProxy(destImageWithPreMultBlender); clippingProxy_pre.clear(new RGBA_Floats(1.0, 1.0, 1.0)); Affine src_mtx = Affine.NewIdentity(); src_mtx *= Affine.NewTranslation(-orignialSize.x / 2 - 10, -orignialSize.y / 2 - 20 - 10); src_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); src_mtx *= Affine.NewScaling(drawScale.Value); src_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); Affine img_mtx = Affine.NewIdentity(); img_mtx *= Affine.NewTranslation(-orignialSize.x / 2 + 10, -orignialSize.y / 2 + 20 + 10); img_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); img_mtx *= Affine.NewScaling(drawScale.Value); img_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); img_mtx.invert(); MatterHackers.Agg.span_allocator sa = new span_allocator(); span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx); span_image_filter sg; switch (sourceImage.BitDepth) { case 24: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgb_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; case 32: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgba_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; default: throw new Exception("Bad sourc depth"); } ScanlineRasterizer ras = new ScanlineRasterizer(); ras.SetVectorClipBox(0, 0, Width, Height); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); //scanline_unpacked_8 sl = new scanline_unpacked_8(); double r = orignialSize.x; if (orignialSize.y - 60 < r) { r = orignialSize.y - 60; } VertexSource.Ellipse ell = new VertexSource.Ellipse(orignialSize.x / 2.0 + 10, orignialSize.y / 2.0 + 20 + 10, r / 2.0 + 16.0, r / 2.0 + 16.0, 200); VertexSourceApplyTransform tr = new VertexSourceApplyTransform(ell, src_mtx); ras.add_path(tr); //clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height()); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg); if (false) // this is test code to check different quality settings for scalling { Vector2 screenCenter = new Vector2(Width / 2, Height / 2); Vector2 deltaToMouse = mousePosition - screenCenter; double angleToMouse = Math.Atan2(deltaToMouse.y, deltaToMouse.x); double diagonalSize = Math.Sqrt(sourceImage.Width * sourceImage.Width + sourceImage.Height * sourceImage.Height); double distToMouse = deltaToMouse.Length; double scalling = distToMouse / diagonalSize; graphics2D.Render(sourceImage, Width / 2, Height / 2, angleToMouse - MathHelper.Tau / 8, scalling, scalling); } base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); if (orignialSize.x == 0) { orignialSize.x = WindowSize.x; orignialSize.y = WindowSize.y; } ImageBuffer destImageWithPreMultBlender = new ImageBuffer(); switch (widgetsSubImage.BitDepth) { case 24: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGR()); break; case 32: destImageWithPreMultBlender.Attach(widgetsSubImage, new BlenderPreMultBGRA()); break; default: throw new Exception("Unknown bit depth"); } ImageClippingProxy clippingProxy_pre = new ImageClippingProxy(destImageWithPreMultBlender); clippingProxy_pre.clear(new RGBA_Floats(1.0, 1.0, 1.0)); Affine src_mtx = Affine.NewIdentity(); src_mtx *= Affine.NewTranslation(-orignialSize.x / 2 - 10, -orignialSize.y / 2 - 20 - 10); src_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); src_mtx *= Affine.NewScaling(drawScale.Value); src_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); Affine img_mtx = Affine.NewIdentity(); img_mtx *= Affine.NewTranslation(-orignialSize.x / 2 + 10, -orignialSize.y / 2 + 20 + 10); img_mtx *= Affine.NewRotation(drawAngle.Value * Math.PI / 180.0); img_mtx *= Affine.NewScaling(drawScale.Value); img_mtx *= Affine.NewTranslation(orignialSize.x / 2, orignialSize.y / 2 + 20); img_mtx.invert(); MatterHackers.Agg.span_allocator sa = new span_allocator(); span_interpolator_linear interpolator = new span_interpolator_linear(img_mtx); span_image_filter sg; switch (sourceImage.BitDepth) { case 24: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgb_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; case 32: { ImageBufferAccessorClip source = new ImageBufferAccessorClip(sourceImage, RGBA_Floats.rgba_pre(0, 0, 0, 0).GetAsRGBA_Bytes()); sg = new span_image_filter_rgba_bilinear_clip(source, RGBA_Floats.rgba_pre(0, 0.4, 0, 0.5), interpolator); } break; default: throw new Exception("Bad sourc depth"); } ScanlineRasterizer ras = new ScanlineRasterizer(); ras.SetVectorClipBox(0, 0, Width, Height); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); //scanline_unpacked_8 sl = new scanline_unpacked_8(); double r = orignialSize.x; if (orignialSize.y - 60 < r) { r = orignialSize.y - 60; } VertexSource.Ellipse ell = new VertexSource.Ellipse(orignialSize.x / 2.0 + 10, orignialSize.y / 2.0 + 20 + 10, r / 2.0 + 16.0, r / 2.0 + 16.0, 200); VertexSourceApplyTransform tr = new VertexSourceApplyTransform(ell, src_mtx); ras.add_path(tr); //clippingProxy_pre.SetClippingBox(30, 0, (int)width(), (int)height()); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy_pre, sa, sg); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); ScanlineRasterizer ras = new ScanlineRasterizer(); scanline_unpacked_8 sl = new scanline_unpacked_8(); ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage); clippingProxy.clear(new RGBA_Floats(0, 0, 0)); m_profile.text_size(8.0); // draw a background to show how the alpha is working int RectWidth = 32; int xoffset = 238; int yoffset = 171; ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); for (int i = 0; i < 7; i++) { for (int j = 0; j < 7; j++) { if ((i + j) % 2 != 0) { VertexSource.RoundedRect rect = new VertexSource.RoundedRect(i * RectWidth + xoffset, j * RectWidth + yoffset, (i + 1) * RectWidth + xoffset, (j + 1) * RectWidth + yoffset, 2); rect.normalize_radius(); ras.add_path(rect); scanlineRenderer.RenderSolid(clippingProxy, ras, sl, new RGBA_Bytes(.9, .9, .9)); } } } double ini_scale = 1.0; Transform.Affine mtx1 = Affine.NewIdentity(); mtx1 *= Affine.NewScaling(ini_scale, ini_scale); mtx1 *= Affine.NewTranslation(center_x, center_y); VertexSource.Ellipse e1 = new MatterHackers.Agg.VertexSource.Ellipse(); e1.init(0.0, 0.0, 110.0, 110.0, 64); Transform.Affine mtx_g1 = Affine.NewIdentity(); mtx_g1 *= Affine.NewScaling(ini_scale, ini_scale); mtx_g1 *= Affine.NewScaling(m_SaveData.m_scale, m_SaveData.m_scale); mtx_g1 *= Affine.NewScaling(m_scale_x, m_scale_y); mtx_g1 *= Affine.NewRotation(m_SaveData.m_angle); mtx_g1 *= Affine.NewTranslation(m_SaveData.m_center_x, m_SaveData.m_center_y); mtx_g1.invert(); RGBA_Bytes[] color_profile = new RGBA_Bytes[256]; // color_type is defined in pixel_formats.h for (int i = 0; i < 256; i++) { color_profile[i] = new RGBA_Bytes(m_spline_r.spline()[i], m_spline_g.spline()[i], m_spline_b.spline()[i], m_spline_a.spline()[i]); } VertexSourceApplyTransform t1 = new VertexSourceApplyTransform(e1, mtx1); IGradient innerGradient = null; switch (m_GradTypeRBox.SelectedIndex) { case 0: innerGradient = new gradient_radial(); break; case 1: innerGradient = new gradient_diamond(); break; case 2: innerGradient = new gradient_x(); break; case 3: innerGradient = new gradient_xy(); break; case 4: innerGradient = new gradient_sqrt_xy(); break; case 5: innerGradient = new gradient_conic(); break; } IGradient outerGradient = null; switch (m_GradWrapRBox.SelectedIndex) { case 0: outerGradient = new gradient_reflect_adaptor(innerGradient); break; case 1: outerGradient = new gradient_repeat_adaptor(innerGradient); break; case 2: outerGradient = new gradient_clamp_adaptor(innerGradient); break; } span_allocator span_alloc = new span_allocator(); color_function_profile colors = new color_function_profile(color_profile, m_profile.gamma()); span_interpolator_linear inter = new span_interpolator_linear(mtx_g1); span_gradient span_gen = new span_gradient(inter, outerGradient, colors, 0, 150); ras.add_path(t1); scanlineRenderer.GenerateAndRender(ras, sl, clippingProxy, span_alloc, span_gen); base.OnDraw(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterNormal = new ImageBuffer(NewGraphics2D().DestImage, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(NewGraphics2D().DestImage, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(new ColorF(0, 0, 0)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); 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); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(127, 127, 127)); e.init(m_x[1], m_y[1], 3, 3, 16); ras.add_path(e); scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(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 Stroke p = new Stroke(r); p.width(1.0); ras.add_path(p); //Renderer.RenderSolid(clippingProxyGamma, ras, sl, new RGBA_Bytes(0, 0, 0)); scanlineRenderer.RenderSolid(clippingProxyGamma, ras, sl, new Color(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(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { ImageClippingProxy ren_base = new ImageClippingProxy(graphics2D.DestImage); ren_base.clear(new RGBA_Floats(1.0, 1.0, .95)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); // 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_img0); pattern_src_brightness_to_alpha_RGBA_Bytes p2 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img1); pattern_src_brightness_to_alpha_RGBA_Bytes p3 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img2); pattern_src_brightness_to_alpha_RGBA_Bytes p4 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img3); pattern_src_brightness_to_alpha_RGBA_Bytes p5 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img4); pattern_src_brightness_to_alpha_RGBA_Bytes p6 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img5); pattern_src_brightness_to_alpha_RGBA_Bytes p7 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img6); pattern_src_brightness_to_alpha_RGBA_Bytes p8 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img7); pattern_src_brightness_to_alpha_RGBA_Bytes p9 = new pattern_src_brightness_to_alpha_RGBA_Bytes(rbuf_img8); pattern_filter_bilinear_RGBA_Bytes fltr = new pattern_filter_bilinear_RGBA_Bytes(); // 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). //-- Create with specifying the source //-- Create uninitialized and set the source line_image_pattern patt = new line_image_pattern(new pattern_filter_bilinear_RGBA_Bytes()); ImageLineRenderer ren_img = new ImageLineRenderer(ren_base, patt); rasterizer_outline_aa ras_img = new rasterizer_outline_aa(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(graphics2D); }
public override void OnDraw(Graphics2D graphics2D) { ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect()); IImageByte backBuffer = widgetsSubImage; GammaLookUpTable gamma = new GammaLookUpTable(m_gamma.Value); IRecieveBlenderByte NormalBlender = new BlenderBGRA(); IRecieveBlenderByte GammaBlender = new BlenderGammaBGRA(gamma); ImageBuffer rasterNormal = new ImageBuffer(); rasterNormal.Attach(backBuffer, NormalBlender); ImageBuffer rasterGamma = new ImageBuffer(); rasterGamma.Attach(backBuffer, GammaBlender); ImageClippingProxy clippingProxyNormal = new ImageClippingProxy(rasterNormal); ImageClippingProxy clippingProxyGamma = new ImageClippingProxy(rasterGamma); clippingProxyNormal.clear(m_white_on_black.Checked ? new ColorF(0, 0, 0) : new ColorF(1, 1, 1)); ScanlineRasterizer ras = new ScanlineRasterizer(); ScanlineCachePacked8 sl = new ScanlineCachePacked8(); 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); ScanlineRenderer scanlineRenderer = new ScanlineRenderer(); scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(127, 127, 127)); e.init(m_x[1], m_y[1], 3, 3, 16); ras.add_path(e); scanlineRenderer.RenderSolid(clippingProxyNormal, ras, sl, new Color(127, 127, 127)); double d = m_offset.Value; // Creating a rounded rectangle VertexSource.RoundedRect r = new VertexSource.RoundedRect(m_x[0] + d, m_y[0] + d, m_x[1] + d, m_y[1] + d, m_radius.Value); r.normalize_radius(); // Drawing as an outline if (!m_DrawAsOutlineCheckBox.Checked) { Stroke p = new Stroke(r); p.width(1.0); ras.add_path(p); } else { ras.add_path(r); } scanlineRenderer.RenderSolid(clippingProxyGamma, ras, sl, m_white_on_black.Checked ? new Color(255, 255, 255) : new Color(0, 0, 0)); base.OnDraw(graphics2D); }
private void _InternalRender(IVertexSource vertexSource, RGBA_Bytes color) { if (_clipBuffer != null) { // DEBUG_saveImageBuffer(_clipBuffer); // DEBUG_saveImageBuffer(this.imb); IAlphaMask alphaMask = new AlphaMaskByteClipped (_clipBuffer, 1, 0); AlphaMaskAdaptor imageAlphaMaskAdaptor = new AlphaMaskAdaptor (aggGc.DestImage, alphaMask); ImageClippingProxy alphaMaskClippingProxy = new ImageClippingProxy (imageAlphaMaskAdaptor); var scanlineRenderer = new ScanlineRenderer (); var rasterizer = new ScanlineRasterizer (); var scanlineCache = new ScanlineCachePacked8(); VertexSourceApplyTransform trans = new VertexSourceApplyTransform(vertexSource, aggGc.GetTransform()); rasterizer.add_path(trans); scanlineRenderer.render_scanlines_aa_solid(alphaMaskClippingProxy,rasterizer,scanlineCache,color); aggGc.DestImage.MarkImageChanged(); } else { aggGc.Render (vertexSource, color); } }