当前位置: 首页>>代码示例>>C#>>正文


C# ImageBuffer.Attach方法代码示例

本文整理汇总了C#中MatterHackers.Agg.Image.ImageBuffer.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# ImageBuffer.Attach方法的具体用法?C# ImageBuffer.Attach怎么用?C# ImageBuffer.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MatterHackers.Agg.Image.ImageBuffer的用法示例。


在下文中一共展示了ImageBuffer.Attach方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDraw

        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);
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:58,代码来源:rounded_rect.cs

示例2: generate_alpha_mask

        unsafe void generate_alpha_mask(int cx, int cy)
        {
            alphaByteArray = new byte[cx * cy];
            {
#if USE_CLIPPING_ALPHA_MASK
                alphaMaskImageBuffer.AttachBuffer(alphaByteArray, 20 * cx + 20, cx - 40, cy - 40, cx, 8, 1);
#else
                alphaMaskImageBuffer.attach(alphaByteArray, (int)cx, (int)cy, cx, 1);
#endif

                ImageBuffer image = new ImageBuffer();
                image.Attach(alphaMaskImageBuffer, new blender_gray(1), 1, 0, 8);
                ImageClippingProxy clippingProxy = new ImageClippingProxy(image);
                ScanlineCachePacked8 sl = new ScanlineCachePacked8();

                clippingProxy.clear(new RGBA_Floats(0));

                VertexSource.Ellipse ellipseForMask = new MatterHackers.Agg.VertexSource.Ellipse();

                System.Random randGenerator = new Random(1432);

                ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
                int i;
                int num = (int)numMasksSlider.Value;
                for (i = 0; i < num; i++)
                {
                    if (i == num - 1)
                    {
                        ellipseForMask.init(Width / 2, Height / 2, 110, 110, 100);
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes(0, 0, 0, 255));

                        ellipseForMask.init(ellipseForMask.originX, ellipseForMask.originY, ellipseForMask.radiusX - 10, ellipseForMask.radiusY - 10, 100);
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes(255, 0, 0, 255));
                    }
                    else
                    {
                        ellipseForMask.init(randGenerator.Next() % cx,
                                 randGenerator.Next() % cy,
                                 randGenerator.Next() % 100 + 20,
                                 randGenerator.Next() % 100 + 20,
                                 100);
                        // set the color to draw into the alpha channel.
                        // there is not very much reason to set the alpha as you will get the amount of 
                        // transparency based on the color you draw.  (you might want some type of different edeg effect but it will be minor).
                        rasterizer.add_path(ellipseForMask);
                        scanlineRenderer.render_scanlines_aa_solid(clippingProxy, rasterizer, sl, new RGBA_Bytes((int)((float)i / (float)num * 255), 0, 0, 255));
                    }

                }
                
                alphaMaskImageBuffer.DettachBuffer();
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:55,代码来源:alpha_mask2.cs

示例3: OnDraw

		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);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:41,代码来源:FontHinting.cs

示例4: OnDraw

		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);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:46,代码来源:aa_demo.cs

示例5: OnDraw

		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			if (!didInit)
			{
				didInit = true;
				OnInitialize();
			}

			if (m_gamma.Value != m_old_gamma)
			{
				m_gamma_lut.SetGamma(m_gamma.Value);
				ImageIO.LoadImageData("spheres.bmp", m_SourceImage);
				//m_SourceImage.apply_gamma_dir(m_gamma_lut);
				m_old_gamma = m_gamma.Value;
			}

			ImageBuffer pixf = new ImageBuffer();
			switch (widgetsSubImage.BitDepth)
			{
				case 24:
					pixf.Attach(widgetsSubImage, new BlenderBGR());
					break;

				case 32:
					pixf.Attach(widgetsSubImage, new BlenderBGRA());
					break;

				default:
					throw new NotImplementedException();
			}

			ImageClippingProxy clippingProxy = new ImageClippingProxy(pixf);

			clippingProxy.clear(new RGBA_Floats(1, 1, 1));

			if (m_trans_type.SelectedIndex < 2)
			{
				// For the affine parallelogram transformations we
				// calculate the 4-th (implicit) point of the parallelogram
				m_quad.SetXN(3, m_quad.GetXN(0) + (m_quad.GetXN(2) - m_quad.GetXN(1)));
				m_quad.SetYN(3, m_quad.GetYN(0) + (m_quad.GetYN(2) - m_quad.GetYN(1)));
			}

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			// draw a background to show how the alpha is working
			int RectWidth = 70;
			int xoffset = 50;
			int yoffset = 50;
			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();

						g_rasterizer.add_path(rect);
						scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(.2, .2, .2));
					}
				}
			}

			//--------------------------
			// Render the "quad" tool and controls
			g_rasterizer.add_path(m_quad);
			scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.1));

			// Prepare the polygon to rasterize. Here we need to fill
			// the destination (transformed) polygon.
			g_rasterizer.SetVectorClipBox(0, 0, Width, Height);
			g_rasterizer.reset();
			int b = 0;
			g_rasterizer.move_to_d(m_quad.GetXN(0) - b, m_quad.GetYN(0) - b);
			g_rasterizer.line_to_d(m_quad.GetXN(1) + b, m_quad.GetYN(1) - b);
			g_rasterizer.line_to_d(m_quad.GetXN(2) + b, m_quad.GetYN(2) + b);
			g_rasterizer.line_to_d(m_quad.GetXN(3) - b, m_quad.GetYN(3) + b);

			//typedef agg::span_allocator<color_type> span_alloc_type;
			span_allocator sa = new span_allocator();
			image_filter_bilinear filter_kernel = new image_filter_bilinear();
			ImageFilterLookUpTable filter = new ImageFilterLookUpTable(filter_kernel, true);

			ImageBufferAccessorClamp source = new ImageBufferAccessorClamp(m_SourceImage);

			stopwatch.Restart();

			switch (m_trans_type.SelectedIndex)
			{
				case 0:
					{
						/*
								agg::trans_affine tr(m_quad.polygon(), g_x1, g_y1, g_x2, g_y2);

								typedef agg::span_interpolator_linear<agg::trans_affine> interpolator_type;
								interpolator_type interpolator(tr);

//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:101,代码来源:image_resample.cs

示例6: OnDraw

		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);
		}
开发者ID:annafeldman,项目名称:agg-sharp,代码行数:92,代码来源:image1.cs

示例7: render_gouraud

		internal void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras, RenderPoint[] points)
		{
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderZBuffer());

			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			span_gen.colors(points[0].color, points[1].color, points[2].color);
			span_gen.triangle(points[0].position.x, points[0].position.y, points[1].position.x, points[1].position.y, points[2].position.x, points[2].position.y);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}
开发者ID:CodeMangler,项目名称:MatterControl,代码行数:16,代码来源:ThumbnailTracer.cs

示例8: OnDraw

		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);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:86,代码来源:component_rendering.cs

示例9: render_gouraud

		//template<class Scanline, class Ras>
		public void render_gouraud(IImageByte backBuffer, IScanlineCache sl, IRasterizer ras)
		{
			double alpha = m_alpha.Value;
			double brc = 1;
#if SourceDepth24
            pixfmt_alpha_blend_rgb pf = new pixfmt_alpha_blend_rgb(backBuffer, new blender_bgr());
#else
			ImageBuffer image = new ImageBuffer();
			image.Attach(backBuffer, new BlenderBGRA());
#endif
			ImageClippingProxy ren_base = new ImageClippingProxy(image);

			MatterHackers.Agg.span_allocator span_alloc = new span_allocator();
			span_gouraud_rgba span_gen = new span_gouraud_rgba();

			ras.gamma(new gamma_linear(0.0, m_gamma.Value));

			double d = m_dilation.Value;

			// Six triangles
			double xc = (m_x[0] + m_x[1] + m_x[2]) / 3.0;
			double yc = (m_y[0] + m_y[1] + m_y[2]) / 3.0;

			double x1 = (m_x[1] + m_x[0]) / 2 - (xc - (m_x[1] + m_x[0]) / 2);
			double y1 = (m_y[1] + m_y[0]) / 2 - (yc - (m_y[1] + m_y[0]) / 2);

			double x2 = (m_x[2] + m_x[1]) / 2 - (xc - (m_x[2] + m_x[1]) / 2);
			double y2 = (m_y[2] + m_y[1]) / 2 - (yc - (m_y[2] + m_y[1]) / 2);

			double x3 = (m_x[0] + m_x[2]) / 2 - (xc - (m_x[0] + m_x[2]) / 2);
			double y3 = (m_y[0] + m_y[2]) / 2 - (yc - (m_y[0] + m_y[2]) / 2);

			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], xc, yc, d);
			ras.add_path(span_gen);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], xc, yc, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			brc = 1 - brc;
			span_gen.colors(new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[0], m_y[0], m_x[1], m_y[1], x1, y1, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 1, 0, alpha),
							new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[1], m_y[1], m_x[2], m_y[2], x2, y2, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);

			span_gen.colors(new RGBA_Floats(0, 0, 1, alpha),
							new RGBA_Floats(1, 0, 0, alpha),
							new RGBA_Floats(brc, brc, brc, alpha));
			span_gen.triangle(m_x[2], m_y[2], m_x[0], m_y[0], x3, y3, d);
			ras.add_path(span_gen);
			scanlineRenderer.GenerateAndRender(ras, sl, ren_base, span_alloc, span_gen);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:77,代码来源:gouraud.cs

示例10: OnDraw

		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);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:33,代码来源:gouraud.cs

示例11: OnDraw

		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());
			ImageClippingProxy clippingProxy = new ImageClippingProxy(widgetsSubImage);
			clippingProxy.clear(new RGBA_Floats(1, 1, 1));
			m_ras.SetVectorClipBox(0, 0, Width, Height);

			Affine move = Affine.NewTranslation(10, 10);

			Perspective shadow_persp = new Perspective(m_shape_bounds.Left, m_shape_bounds.Bottom,
												m_shape_bounds.Right, m_shape_bounds.Top,
												m_shadow_ctrl.polygon());

			IVertexSource shadow_trans;
			if (m_FlattenCurves.Checked)
			{
				shadow_trans = new VertexSourceApplyTransform(m_shape, shadow_persp);
			}
			else
			{
				shadow_trans = new VertexSourceApplyTransform(m_path, shadow_persp);
				// this will make it very smooth after the transform
				//shadow_trans = new conv_curve(shadow_trans);
			}

			// Render shadow
			m_ras.add_path(shadow_trans);
			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			scanlineRenderer.RenderSolid(clippingProxy, m_ras, m_sl, new RGBA_Floats(0.2, 0.3, 0).GetAsRGBA_Bytes());

			// Calculate the bounding box and extend it by the blur radius
			RectangleDouble bbox = new RectangleDouble();
			bounding_rect.bounding_rect_single(shadow_trans, 0, ref bbox);

			bbox.Left -= m_radius.Value;
			bbox.Bottom -= m_radius.Value;
			bbox.Right += m_radius.Value;
			bbox.Top += m_radius.Value;

			if (m_method.SelectedIndex == 1)
			{
				// The recursive blur method represents the true Gaussian Blur,
				// with theoretically infinite kernel. The restricted window size
				// results in extra influence of edge pixels. It's impossible to
				// solve correctly, but extending the right and top areas to another
				// radius value produces fair result.
				//------------------
				bbox.Right += m_radius.Value;
				bbox.Top += m_radius.Value;
			}

			stopwatch.Restart();

			if (m_method.SelectedIndex != 2)
			{
				// Create a new pixel renderer and attach it to the main one as a child image.
				// It returns true if the attachment succeeded. It fails if the rectangle
				// (bbox) is fully clipped.
				//------------------
#if SourceDepth24
                ImageBuffer image2 = new ImageBuffer(new BlenderBGR());
#else
				ImageBuffer image2 = new ImageBuffer(new BlenderBGRA());
#endif
				if (image2.Attach(widgetsSubImage, (int)bbox.Left, (int)bbox.Bottom, (int)bbox.Right, (int)bbox.Top))
				{
					// Blur it
					if (m_method.SelectedIndex == 0)
					{
						// More general method, but 30-40% slower.
						//------------------
						//m_stack_blur.blur(pixf2, agg::uround(m_radius.Value));

						// Faster, but bore specific.
						// Works only for 8 bits per channel and only with radii <= 254.
						//------------------
						stack_blur test = new stack_blur();
						test.Blur(image2, agg_basics.uround(m_radius.Value), agg_basics.uround(m_radius.Value));
					}
					else
					{
						// True Gaussian Blur, 3-5 times slower than Stack Blur,
						// but still constant time of radius. Very sensitive
						// to precision, doubles are must here.
						//------------------
						m_recursive_blur.blur(image2, m_radius.Value);
					}
				}
			}
			else
			{
				/*
				// Blur separate channels
				//------------------
				if(m_channel_r.Checked)
				{
					typedef agg::pixfmt_alpha_blend_gray<
						agg::blender_gray8,
						agg::rendering_buffer,
						3, 2> pixfmt_gray8r;
//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:101,代码来源:blur.cs

示例12: OnDraw

		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			IImageByte backBuffer = widgetsSubImage;

			if (!didInit)
			{
				didInit = true;
				OnInitialize();
			}
			ImageBuffer image;
			if (backBuffer.BitDepth == 32)
			{
				image = new ImageBuffer();
				image.Attach(backBuffer, new BlenderBGRA());
			}
			else
			{
				if (backBuffer.BitDepth != 24)
				{
					throw new System.NotSupportedException();
				}
				image = new ImageBuffer();
				image.Attach(backBuffer, new BlenderBGR());
			}
			ImageClippingProxy clippingProxy = new ImageClippingProxy(image);
			clippingProxy.clear(new RGBA_Floats(1, 1, 1));

			g_rasterizer.SetVectorClipBox(0, 0, Width, Height);

			ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
			if (transformationTypeRadioButton.SelectedIndex == 0)
			{
				Bilinear tr = new Bilinear(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
				if (tr.is_valid())
				{
					//--------------------------
					// Render transformed lion
					//
					VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

					scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
					//--------------------------

					//--------------------------
					// Render transformed ellipse
					//
					VertexSource.Ellipse ell = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
									 (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
									 200);
					Stroke ell_stroke = new Stroke(ell);
					ell_stroke.width(3.0);
					VertexSourceApplyTransform trans_ell = new VertexSourceApplyTransform(ell, tr);

					VertexSourceApplyTransform trans_ell_stroke = new VertexSourceApplyTransform(ell_stroke, tr);

					g_rasterizer.add_path(trans_ell);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

					g_rasterizer.add_path(trans_ell_stroke);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
				}
			}
			else
			{
				Perspective tr = new Perspective(lionShape.Bounds.Left, lionShape.Bounds.Bottom, lionShape.Bounds.Right, lionShape.Bounds.Top, quadPolygonControl.polygon());
				if (tr.is_valid())
				{
					// Render transformed lion
					VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, tr);

					scanlineRenderer.RenderSolidAllPaths(clippingProxy, g_rasterizer, g_scanline, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

					// Render transformed ellipse
					VertexSource.Ellipse FilledEllipse = new MatterHackers.Agg.VertexSource.Ellipse((lionShape.Bounds.Left + lionShape.Bounds.Right) * 0.5, (lionShape.Bounds.Bottom + lionShape.Bounds.Top) * 0.5,
									 (lionShape.Bounds.Right - lionShape.Bounds.Left) * 0.5, (lionShape.Bounds.Top - lionShape.Bounds.Bottom) * 0.5,
									 200);

					Stroke EllipseOutline = new Stroke(FilledEllipse);
					EllipseOutline.width(3.0);
					VertexSourceApplyTransform TransformedFilledEllipse = new VertexSourceApplyTransform(FilledEllipse, tr);

					VertexSourceApplyTransform TransformedEllipesOutline = new VertexSourceApplyTransform(EllipseOutline, tr);

					g_rasterizer.add_path(TransformedFilledEllipse);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.5, 0.3, 0.0, 0.3));

					g_rasterizer.add_path(TransformedEllipesOutline);
					scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0.0, 0.3, 0.2, 1.0));
				}
			}

			//--------------------------
			// Render the "quad" tool and controls
			g_rasterizer.add_path(quadPolygonControl);
			scanlineRenderer.RenderSolid(clippingProxy, g_rasterizer, g_scanline, new RGBA_Bytes(0, 0.3, 0.5, 0.6));
			//m_trans_type.Render(g_rasterizer, g_scanline, clippingProxy);
			base.OnDraw(graphics2D);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:100,代码来源:perspective.cs

示例13: OnDraw

		public override void OnDraw(Graphics2D graphics2D)
		{
			ImageBuffer widgetsSubImage = ImageBuffer.NewSubImageReference(graphics2D.DestImage, graphics2D.GetClippingRect());

			int width = (int)widgetsSubImage.Width;
			int height = (int)widgetsSubImage.Height;

			ImageBuffer clippedSubImage = new ImageBuffer();
			clippedSubImage.Attach(widgetsSubImage, new BlenderBGRA());
			ImageClippingProxy imageClippingProxy = new ImageClippingProxy(clippedSubImage);
			imageClippingProxy.clear(new RGBA_Floats(1, 1, 1));

			Affine transform = Affine.NewIdentity();
			transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y);
			transform *= Affine.NewScaling(lionScale, lionScale);
			transform *= Affine.NewRotation(angle + Math.PI);
			transform *= Affine.NewSkewing(skewX / 1000.0, skewY / 1000.0);
			transform *= Affine.NewTranslation(width / 2, height / 2);

			if (renderAsScanlineCheckBox.Checked)
			{
				rasterizer.SetVectorClipBox(0, 0, width, height);

				Stroke stroke = new Stroke(lionShape.Path);
				stroke.width(widthSlider.Value);
				stroke.line_join(LineJoin.Round);
				VertexSourceApplyTransform trans = new VertexSourceApplyTransform(stroke, transform);
				ScanlineRenderer scanlineRenderer = new ScanlineRenderer();
				scanlineRenderer.RenderSolidAllPaths(imageClippingProxy, rasterizer, scanlineCache, trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
			}
			else
			{
				double w = widthSlider.Value * transform.GetScale();

				LineProfileAnitAlias lineProfile = new LineProfileAnitAlias(w, new gamma_none());
				OutlineRenderer outlineRenderer = new OutlineRenderer(imageClippingProxy, lineProfile);
				rasterizer_outline_aa rasterizer = new rasterizer_outline_aa(outlineRenderer);

				rasterizer.line_join(renderAccurateJoinsCheckBox.Checked ?
					rasterizer_outline_aa.outline_aa_join_e.outline_miter_accurate_join
					: rasterizer_outline_aa.outline_aa_join_e.outline_round_join);
				rasterizer.round_cap(true);

				VertexSourceApplyTransform trans = new VertexSourceApplyTransform(lionShape.Path, transform);

				rasterizer.RenderAllPaths(trans, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);
			}

			base.OnDraw(graphics2D);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:50,代码来源:lion_outline.cs


注:本文中的MatterHackers.Agg.Image.ImageBuffer.Attach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。