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


C# ImageBuffer.NewGraphics2D方法代码示例

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


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

示例1: TextWidgetVisibleTest

		public void TextWidgetVisibleTest()
		{
			{
				GuiWidget rectangleWidget = new GuiWidget(100, 50);
				TextWidget itemToAdd = new TextWidget("test Item", 10, 10);
				rectangleWidget.AddChild(itemToAdd);
				rectangleWidget.DoubleBuffer = true;
				rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
				rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D());

				ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA());
				textOnly.NewGraphics2D().Clear(RGBA_Bytes.White);

				textOnly.NewGraphics2D().DrawString("test Item", 1, 1);

				if (saveImagesForDebug)
				{
					ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga");
					//ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga");
					ImageTgaIO.Save(textOnly, "-textOnly.tga");
				}

				Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing.");
				rectangleWidget.Close();
			}

			{
				GuiWidget rectangleWidget = new GuiWidget(100, 50);
				TextEditWidget itemToAdd = new TextEditWidget("test Item", 10, 10);
				rectangleWidget.AddChild(itemToAdd);
				rectangleWidget.DoubleBuffer = true;
				rectangleWidget.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
				rectangleWidget.OnDraw(rectangleWidget.BackBuffer.NewGraphics2D());

				ImageBuffer textOnly = new ImageBuffer(75, 20, 32, new BlenderBGRA());
				textOnly.NewGraphics2D().Clear(RGBA_Bytes.White);

				TypeFacePrinter stringPrinter = new TypeFacePrinter("test Item", 12);
				IVertexSource offsetText = new VertexSourceApplyTransform(stringPrinter, Affine.NewTranslation(1, -stringPrinter.LocalBounds.Bottom));
				textOnly.NewGraphics2D().Render(offsetText, RGBA_Bytes.Black);

				if (saveImagesForDebug)
				{
					ImageTgaIO.Save(rectangleWidget.BackBuffer, "-rectangleWidget.tga");
					//ImageTgaIO.Save(itemToAdd.Children[0].BackBuffer, "-internalTextWidget.tga");
					ImageTgaIO.Save(textOnly, "-textOnly.tga");
				}

				Assert.IsTrue(rectangleWidget.BackBuffer.FindLeastSquaresMatch(textOnly, 1), "TextWidgets need to be drawing.");
				rectangleWidget.Close();
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:52,代码来源:TextAndTextWidgetTests.cs

示例2: DoubleBufferTests

		public void DoubleBufferTests()
		{
			{
				bool textWidgetDoubleBufferDefault = TextWidget.DoubleBufferDefault;

				// the text widget is double buffered
				TextWidget.DoubleBufferDefault = true;
				ImageBuffer doubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
				Button doubleBufferButton = new Button("testing", 0, 0);
				doubleBufferButton.OnDraw(doubleBufferImage.NewGraphics2D());
				SaveImage(doubleBufferImage, "z control.tga");

				// make sure the frame comparison function works.
				{
					ImageBuffer doubleBufferImageCopy = new ImageBuffer(doubleBufferImage, new BlenderBGR());
					Assert.IsTrue(doubleBufferImage == doubleBufferImageCopy);
				}

				// the text widget is not double buffered
				TextWidget.DoubleBufferDefault = false;
				ImageBuffer notDoubleBufferImage = new ImageBuffer(65, 50, 24, new BlenderBGR());
				Button notDoubleBufferButton = new Button("testing", 0, 0);
				notDoubleBufferButton.OnDraw(notDoubleBufferImage.NewGraphics2D());
				SaveImage(notDoubleBufferImage, "z test.tga");

				Assert.IsTrue(doubleBufferImage == notDoubleBufferImage);

				TextWidget.DoubleBufferDefault = textWidgetDoubleBufferDefault;
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:30,代码来源:BackBufferTests.cs

示例3: ContainsTests

		public void ContainsTests()
		{
			// look for 24 bit
			{
				ImageBuffer imageToSearch = new ImageBuffer(150, 150, 24, new BlenderBGR());
				imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
				ImageBuffer circleToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
				circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
				Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");

				ImageBuffer squareToFind = new ImageBuffer(10, 10, 24, new BlenderBGR());
				squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
				Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
			}

			// look for 32 bit
			{
				ImageBuffer imageToSearch = new ImageBuffer(150, 150, 32, new BlenderBGRA());
				imageToSearch.NewGraphics2D().Circle(new Vector2(100, 100), 3, RGBA_Bytes.Red);
				ImageBuffer circleToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				circleToFind.NewGraphics2D().Circle(new Vector2(5, 5), 3, RGBA_Bytes.Red);
				Assert.IsTrue(imageToSearch.Contains(circleToFind), "We should be able to find the circle.");

				ImageBuffer squareToFind = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				squareToFind.NewGraphics2D().FillRectangle(4, 4, 8, 8, RGBA_Bytes.Red);
				Assert.IsTrue(!imageToSearch.Contains(squareToFind), "We should be not find a square.");
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:28,代码来源:ImageTests.cs

示例4: RandomFillWidget

		public RandomFillWidget(Point2D size)
		{
			LocalBounds = new RectangleDouble(0, 0, size.x, size.y);
			image = new ImageBuffer(size.x, size.y, 32, new BlenderBGRA());

			Random rand = new Random();
			Graphics2D imageGraphics = image.NewGraphics2D();
			for (int i = 0; i < 30; i++)
			{
				imageGraphics.Circle(rand.NextDouble() * image.Width, rand.NextDouble() * image.Height, rand.NextDouble() * 10 + 5, RGBA_Bytes.Red);
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:12,代码来源:ScrollableWidgetTestPage.cs

示例5: ClearAndCheckImage

		private bool ClearAndCheckImage(ImageBuffer image, RGBA_Bytes color)
		{
			image.NewGraphics2D().Clear(color);

			for (int y = 0; y < image.Height; y++)
			{
				for (int x = 0; x < image.Width; x++)
				{
					if (image.GetPixel(x, y) != color)
					{
						return false;
					}
				}
			}

			return true;
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:17,代码来源:ImageTests.cs

示例6: DebugRenderToImage

		public DebugRenderToImage(Mesh meshToRender)
		{
			this.meshToRender = meshToRender;
			image = new ImageBuffer(xResolution, yResolution, 32, new BlenderBGRA());
			graphics = image.NewGraphics2D();

			// assume project on y for now
			foreach (Vertex vertex in meshToRender.Vertices)
			{
				min.x = Math.Min(min.x, vertex.Position[xAxis]);
				min.y = Math.Min(min.y, vertex.Position[yAxis]);

				max.x = Math.Max(max.x, vertex.Position[xAxis]);
				max.y = Math.Max(max.y, vertex.Position[yAxis]);
			}

			scale = Math.Min((image.Width - padding * 2) / (max.x - min.x), (image.Height - padding * 2) / (max.y - min.y));
			origin = new Vector2(min.x * scale, min.y * scale) - new Vector2(padding, padding);
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:19,代码来源:DebugRenderToImage.cs

示例7: CompareToLionTGA

		public void CompareToLionTGA()
		{
			LionShape lionShape = new LionShape();
			ImageBuffer renderedImage = new ImageBuffer(512, 400, 24, new BlenderBGR());
			byte alpha = (byte)(.1 * 255);
			for (int i = 0; i < lionShape.NumPaths; i++)
			{
				lionShape.Colors[i].Alpha0To255 = alpha;
			}

			Affine transform = Affine.NewIdentity();
			transform *= Affine.NewTranslation(-lionShape.Center.x, -lionShape.Center.y);
			transform *= Affine.NewTranslation(renderedImage.Width / 2, renderedImage.Height / 2);

			// This code renders the lion:
			VertexSourceApplyTransform transformedPathStorage = new VertexSourceApplyTransform(lionShape.Path, transform);
			Graphics2D renderer = renderedImage.NewGraphics2D();
			renderer.Clear(new RGBA_Floats(1.0, 1.0, 1.0, 1.0));
			renderer.Render(transformedPathStorage, lionShape.Colors, lionShape.PathIndex, lionShape.NumPaths);

			ImageTgaIO.Save(renderedImage, "TestOutput.tga");

			Stream imageStream = File.Open("LionRenderMaster.tga", FileMode.Open);
			ImageBuffer masterImage = new ImageBuffer();
			ImageTgaIO.LoadImageData(masterImage, imageStream, 24);

			bool sameWidth = masterImage.Width == renderedImage.Width;
			bool sameHeight = masterImage.Height == renderedImage.Height;
			Assert.IsTrue(sameWidth && sameHeight);
			Assert.IsTrue(masterImage.BitDepth == renderedImage.BitDepth);
			int unused;
			byte[] masterBuffer = masterImage.GetBuffer(out unused);
			byte[] renderedBuffer = renderedImage.GetBuffer(out unused);
			Assert.IsTrue(masterBuffer.Length == renderedBuffer.Length);
			for (int i = 0; i < masterBuffer.Length; i++)
			{
				if (masterBuffer[i] != renderedBuffer[i])
				{
					Assert.IsTrue(false);
				}
			}
		}
开发者ID:glocklueng,项目名称:agg-sharp,代码行数:42,代码来源:LionRenderTest.cs

示例8: FloodFillDemo

        public FloodFillDemo()
        {
            BackgroundColor = RGBA_Bytes.White;
            imageToFillOn = new ImageBuffer(400, 300, 32, new BlenderBGRA());
            Graphics2D imageToFillGraphics = imageToFillOn.NewGraphics2D();
            imageToFillGraphics.Clear(RGBA_Bytes.White);
            imageToFillGraphics.DrawString("Click to fill", 20, 30);
            imageToFillGraphics.Circle(new Vector2(200, 150), 35, RGBA_Bytes.Black);
            imageToFillGraphics.Circle(new Vector2(200, 150), 30, RGBA_Bytes.Green);
            imageToFillGraphics.Rectangle(20, 50, 210, 280, RGBA_Bytes.Black);
            imageToFillGraphics.Rectangle(imageToFillOn.GetBounds(), RGBA_Bytes.Blue);

            Random rand = new Random();
            for (int i = 0; i < 20; i++)
            {
                Ellipse elipse = new Ellipse(rand.Next(imageToFillOn.Width), rand.Next(imageToFillOn.Height), rand.Next(10, 60), rand.Next(10, 60));
                Stroke outline = new Stroke(elipse);
                imageToFillGraphics.Render(outline, RGBA_Bytes.Black);
            }
            

            m_slider1 = new Slider(new Vector2(80, 10), 510);
            m_slider2 = new Slider(new Vector2(80, 10 + 20), 510);

            m_slider1.ValueChanged += new EventHandler(NeedsRedraw);
            m_slider2.ValueChanged += new EventHandler(NeedsRedraw);

            AddChild(m_slider1);
            AddChild(m_slider2);

            m_slider1.Text = "Pixel size={0:F3}";
            m_slider1.SetRange(8, 100);
            m_slider1.NumTicks = 23;
            m_slider1.Value = 32;

            m_slider2.Text = "gamma={0:F3}";
            m_slider2.SetRange(0.0, 3.0);
            m_slider2.Value = 1.0;
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:39,代码来源:FloodFill.cs

示例9: CreateText

        public static CCSprite CreateText(string text, CCColor4B fill, CCColor4B stroke, TypeFace font, double emSizeInPoints, bool underline = false, bool flatenCurves = true, double strokeThickness = 1)
        {
            TypeFacePrinter printer = new TypeFacePrinter(text, new StyledTypeFace(font, emSizeInPoints, underline, flatenCurves));
            double width = printer.LocalBounds.Width;
            double height = printer.LocalBounds.Height;

            RectangleDouble rect = new RectangleDouble();
            bounding_rect.bounding_rect_single(printer, 0, ref rect);
            VertexSourceApplyTransform path = new VertexSourceApplyTransform(printer, Affine.NewTranslation(-rect.Left, -rect.Bottom));

            ImageBuffer buffer = new ImageBuffer((int)width, (int)height, 32, new BlenderRGBA());
            Graphics2D g = buffer.NewGraphics2D();

            if (fill.A > 0) g.Render(path, new RGBA_Bytes(fill.R, fill.G, fill.B, fill.A));
            if (stroke.A > 0) g.Render(new Stroke(path, strokeThickness), new RGBA_Bytes(stroke.R, stroke.G, stroke.B, stroke.A));

            Texture2D xnaTexture = XnaTexture((int)width, (int)height);
            xnaTexture.SetData<byte>(buffer.GetBuffer());
            CCTexture2D ccTexture = new CCTexture2D();
            ccTexture.InitWithTexture(xnaTexture);
            return new CCSprite(ccTexture);
        }
开发者ID:liwq-net,项目名称:UIFactory,代码行数:22,代码来源:UIFactory.cs

示例10: AddAFloor

		private void AddAFloor()
		{
			ImageBuffer testImage = new ImageBuffer(200, 200, 32, new BlenderBGRA());
			Graphics2D graphics = testImage.NewGraphics2D();
			Random rand = new Random(0);
			for (int i = 0; i < 100; i++)
			{
				RGBA_Bytes color = new RGBA_Bytes(rand.NextDouble(), rand.NextDouble(), rand.NextDouble());
				graphics.Circle(new Vector2(rand.NextDouble() * testImage.Width, rand.NextDouble() * testImage.Height), rand.NextDouble() * 40 + 10, color);
			}
			scene.shapes.Add(new PlaneShape(new Vector3(0, 0, 1), 0, new TextureMaterial(testImage, 0, 0, .2, 1)));
			//scene.shapes.Add(new PlaneShape(new Vector3(0, 0, 1), 0, new ChessboardMaterial(new RGBA_Floats(1, 1, 1), new RGBA_Floats(0, 0, 0), 0, 0, 1, 0.7)));
		}
开发者ID:CodeMangler,项目名称:MatterControl,代码行数:13,代码来源:ThumbnailTracer.cs

示例11: GetThumbnailWidget

		protected GuiWidget GetThumbnailWidget(LibraryProvider parentProvider, PrintItemCollection printItemCollection, ImageBuffer imageBuffer)
		{
			Vector2 expectedSize = new Vector2((int)(50 * TextWidget.GlobalPointSizeScaleRatio), (int)(50 * TextWidget.GlobalPointSizeScaleRatio));
			if (imageBuffer.Width != expectedSize.x)
			{
				ImageBuffer scaledImageBuffer = new ImageBuffer((int)expectedSize.x, (int)expectedSize.y, 32, new BlenderBGRA());
				scaledImageBuffer.NewGraphics2D().Render(imageBuffer, 0, 0, scaledImageBuffer.Width, scaledImageBuffer.Height);
				imageBuffer = scaledImageBuffer;
			}

			ImageWidget folderThumbnail = new ImageWidget(imageBuffer);
			folderThumbnail.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;

			Button clickThumbnail = new Button(0, 0, folderThumbnail);
			clickThumbnail.Cursor = Cursors.Hand;

			clickThumbnail.Click += (sender, e) =>
			{
				if (parentProvider == null)
				{
					this.CurrentLibraryProvider = this.CurrentLibraryProvider.GetProviderForCollection(printItemCollection);
				}
				else
				{
					this.CurrentLibraryProvider = parentProvider;
				}
			};

			return clickThumbnail;
		}
开发者ID:gobrien4418,项目名称:MatterControl,代码行数:30,代码来源:LibraryDataView.cs

示例12: client_DownloadDataCompleted

		void client_DownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)
		{
			try // if we get a bad result we can get a target invocation exception. In that case just don't show anything
			{
				byte[] raw = e.Result;
				Stream stream = new MemoryStream(raw);
				ImageBuffer unScaledImage = new ImageBuffer(10, 10, 32, new BlenderBGRA());
				StaticData.Instance.LoadImageData(stream, unScaledImage);
				// If the source image (the one we downloaded) is more than twice as big as our dest image.
				while (unScaledImage.Width > Image.Width * 2)
				{
					// The image sampler we use is a 2x2 filter so we need to scale by a max of 1/2 if we want to get good results.
					// So we scale as many times as we need to to get the Image to be the right size.
					// If this were going to be a non-uniform scale we could do the x and y separately to get better results.
					ImageBuffer halfImage = new ImageBuffer(unScaledImage.Width / 2, unScaledImage.Height / 2, 32, scalingBlender);
					halfImage.NewGraphics2D().Render(unScaledImage, 0, 0, 0, halfImage.Width / (double)unScaledImage.Width, halfImage.Height / (double)unScaledImage.Height);
					unScaledImage = halfImage;
				}
				Image.NewGraphics2D().Render(unScaledImage, 0, 0, 0, Image.Width / (double)unScaledImage.Width, Image.Height / (double)unScaledImage.Height);
				Image.MarkImageChanged();
				Invalidate();

				if (LoadComplete != null)
				{
					LoadComplete(this, null);
				}
			}
			catch (Exception)
			{
				GuiWidget.BreakInDebugger();
			}
		}
开发者ID:broettge,项目名称:MatterControl,代码行数:32,代码来源:ImageWidget_AsyncLoadOnDraw.cs

示例13: SingleItemVisibleTest

        public void SingleItemVisibleTest()
        {
            {
                ListBox containerListBox = new ListBox(new RectangleDouble(0, 0, 100, 100));
                ListBoxTextItem itemToAddToList = new ListBoxTextItem("test Item", "test data for item");
                itemToAddToList.Name = "list item";
                containerListBox.AddChild(itemToAddToList);
                containerListBox.DoubleBuffer = true;
                containerListBox.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
                containerListBox.OnDraw(containerListBox.BackBuffer.NewGraphics2D());

                ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA());
                textImage.NewGraphics2D().Clear(RGBA_Bytes.White);
                textImage.NewGraphics2D().DrawString("test Item", 1, 1);

                OutputImage(containerListBox.BackBuffer, "test.tga");
                OutputImage(textImage, "control.tga");

                double maxError = 20000000;
                Vector2 bestPosition;
                double leastSquares;
                containerListBox.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError);

                Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it.");
            }

            {
                GuiWidget container = new GuiWidget(202, 302);
                container.DoubleBuffer = true;
                container.NewGraphics2D().Clear(RGBA_Bytes.White);
                FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget();
                leftToRightLayout.AnchorAll();
                {
                    {
                        ListBox listBox = new ListBox(new RectangleDouble(0, 0, 200, 300));
                        //listBox.BackgroundColor = RGBA_Bytes.Red;
                        listBox.Name = "listBox";
                        listBox.VAnchor = UI.VAnchor.ParentTop;
                        listBox.ScrollArea.Margin = new BorderDouble(15);
                        leftToRightLayout.AddChild(listBox);

                        for (int i = 0; i < 1; i++)
                        {
                            ListBoxTextItem newItem = new ListBoxTextItem("hand" + i.ToString() + ".stl", "c:\\development\\hand" + i.ToString() + ".stl");
                            newItem.Name = "ListBoxItem" + i.ToString();
                            listBox.AddChild(newItem);
                        }
                    }
                }

                container.AddChild(leftToRightLayout);
                container.OnDraw(container.NewGraphics2D());

                ImageBuffer textImage = new ImageBuffer(80, 16, 32, new BlenderBGRA());
                textImage.NewGraphics2D().Clear(RGBA_Bytes.White);
                textImage.NewGraphics2D().DrawString("hand0.stl", 1, 1);

                OutputImage(container.BackBuffer, "control.tga");
                OutputImage(textImage, "test.tga");

                double maxError = 1000000;
                Vector2 bestPosition;
                double leastSquares;
                container.BackBuffer.FindLeastSquaresMatch(textImage, out bestPosition, out leastSquares, maxError);

                Assert.IsTrue(leastSquares < maxError, "The list box need to be showing the item we added to it.");
            }
        }
开发者ID:jeske,项目名称:agg-sharp,代码行数:68,代码来源:ListBoxTests.cs

示例14: BuildImageFromMeshGroups

		private static ImageBuffer BuildImageFromMeshGroups(List<MeshGroup> loadedMeshGroups, string stlHashCode, Point2D size)
		{
			if (loadedMeshGroups != null
				&& loadedMeshGroups.Count > 0
				&& loadedMeshGroups[0].Meshes != null
				&& loadedMeshGroups[0].Meshes[0] != null)
			{
				ImageBuffer tempImage = new ImageBuffer(size.x, size.y);
				Graphics2D partGraphics2D = tempImage.NewGraphics2D();
				partGraphics2D.Clear(new RGBA_Bytes());

				AxisAlignedBoundingBox aabb = loadedMeshGroups[0].GetAxisAlignedBoundingBox();
				for (int meshGroupIndex = 1; meshGroupIndex < loadedMeshGroups.Count; meshGroupIndex++)
				{
					aabb = AxisAlignedBoundingBox.Union(aabb, loadedMeshGroups[meshGroupIndex].GetAxisAlignedBoundingBox());
				}
				double maxSize = Math.Max(aabb.XSize, aabb.YSize);
				double scale = size.x / (maxSize * 1.2);
				RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
				foreach (MeshGroup meshGroup in loadedMeshGroups)
				{
					foreach (Mesh loadedMesh in meshGroup.Meshes)
					{
						PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh,
							new Vector2((size.x / scale - bounds2D.Width) / 2 - bounds2D.Left,
								(size.y / scale - bounds2D.Height) / 2 - bounds2D.Bottom),
							scale, RGBA_Bytes.White);
					}
				}

				if (File.Exists("RunUnitTests.txt"))
				{
					foreach (Mesh loadedMesh in loadedMeshGroups[0].Meshes)
					{
						List<MeshEdge> nonManifoldEdges = loadedMesh.GetNonManifoldEdges();
						if (nonManifoldEdges.Count > 0)
						{
							partGraphics2D.Circle(size.x / 4, size.x / 4, size.x / 8, RGBA_Bytes.Red);
						}
					}
				}

				tempImage.SetRecieveBlender(new BlenderPreMultBGRA());
				AllWhite.DoAllWhite(tempImage);

				// and give it back
				return tempImage;
			}

			return null;
		}
开发者ID:unlimitedbacon,项目名称:MatterControl,代码行数:51,代码来源:PartThumbnailWidget.cs

示例15: CreateThumbnail

		private void CreateThumbnail()
		{
			string stlHashCode = this.ItemWrapper.FileHashCode.ToString();

			ImageBuffer bigRender = new ImageBuffer();
			if (!File.Exists(this.ItemWrapper.FileLocation))
			{
				return;
			}

			List<MeshGroup> loadedMeshGroups = MeshFileIo.Load(this.ItemWrapper.FileLocation);

			RenderType renderType = GetRenderType(this.ItemWrapper.FileLocation);

			switch (renderType)
			{
				case RenderType.RAY_TRACE:
					{
						ThumbnailTracer tracer = new ThumbnailTracer(loadedMeshGroups, BigRenderSize.x, BigRenderSize.y);
						tracer.DoTrace();

						bigRender = tracer.destImage;
					}
					break;

				case RenderType.PERSPECTIVE:
					{
						ThumbnailTracer tracer = new ThumbnailTracer(loadedMeshGroups, BigRenderSize.x, BigRenderSize.y);
						this.thumbnailImage = new ImageBuffer(this.buildingThumbnailImage);
						this.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0));

						bigRender = new ImageBuffer(BigRenderSize.x, BigRenderSize.y);

						foreach (MeshGroup meshGroup in loadedMeshGroups)
						{
							double minZ = double.MaxValue;
							double maxZ = double.MinValue;
							foreach (Mesh loadedMesh in meshGroup.Meshes)
							{
								tracer.GetMinMaxZ(loadedMesh, ref minZ, ref maxZ);
							}

							foreach (Mesh loadedMesh in meshGroup.Meshes)
							{
								tracer.DrawTo(bigRender.NewGraphics2D(), loadedMesh, RGBA_Bytes.White, minZ, maxZ);
							}
						}

						if (bigRender == null)
						{
							bigRender = new ImageBuffer(this.noThumbnailImage);
						}
					}
					break;

				case RenderType.NONE:
				case RenderType.ORTHOGROPHIC:

					this.thumbnailImage = new ImageBuffer(this.buildingThumbnailImage);
					this.thumbnailImage.NewGraphics2D().Clear(new RGBA_Bytes(255, 255, 255, 0));
					bigRender = BuildImageFromMeshGroups(loadedMeshGroups, stlHashCode, BigRenderSize);
					if (bigRender == null)
					{
						bigRender = new ImageBuffer(this.noThumbnailImage);
					}
					break;
			}

			// and save it to disk
			string imageFileName = GetImageFileName(stlHashCode);

			if (partExtension == ".png")
			{
				ImageIO.SaveImageData(imageFileName, bigRender);
			}
			else
			{
				ImageTgaIO.SaveImageData(imageFileName, bigRender);
			}

			bigRender.SetRecieveBlender(new BlenderPreMultBGRA());

			this.thumbnailImage = ImageBuffer.CreateScaledImage(bigRender, (int)Width, (int)Height);

			UiThread.RunOnIdle(this.EnsureImageUpdated);

			OnDoneRendering();
		}
开发者ID:unlimitedbacon,项目名称:MatterControl,代码行数:88,代码来源:PartThumbnailWidget.cs


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