2
다각형을 만들려면 아래 코드를 사용하십시오. 난 그냥 검은 점 으로이 다각형 표면을 채우기 위해, 내가 어떻게 할 수있는 다음,이 폴리곤을 비트 맵이나 메모리 스트림으로 변환하고 싶습니다. 어떻게해야합니까 ??도트로 채워지는 다각형 만들기
// Create a blue and a black Brush
SolidColorBrush yellowBrush = new SolidColorBrush();
yellowBrush.Color = Colors.Transparent;
SolidColorBrush blackBrush = new SolidColorBrush();
blackBrush.Color = Colors.Black;
// Create a Polygon
Polygon yellowPolygon = new Polygon();
yellowPolygon.Stroke = blackBrush;
yellowPolygon.Fill = yellowBrush;
yellowPolygon.StrokeThickness = 4;
// Create a collection of points for a polygon
System.Windows.Point Point1 = new System.Windows.Point(50, 100);
System.Windows.Point Point2 = new System.Windows.Point(200, 100);
System.Windows.Point Point3 = new System.Windows.Point(200, 200);
System.Windows.Point Point4 = new System.Windows.Point(300, 30);
PointCollection polygonPoints = new PointCollection();
polygonPoints.Add(Point1);
polygonPoints.Add(Point2);
polygonPoints.Add(Point3);
polygonPoints.Add(Point4);
// Set Polygon.Points properties
yellowPolygon.Points = polygonPoints;
// Add Polygon to the page
mygrid.Children.Add(yellowPolygon);
, 않기 위해, 단지 점선 패턴 모든 먹으 렴을하고 XAML 코드를 사용하고 있지 않다 여기, 그냥 그 이미지를 만들고 비트 맵으로 저장 하시겠습니까 ??? –
@ deep : 코드 예제를 제공하기 위해 내 게시물을 편집했습니다. 그러나이 다각형을 비트 맵으로 저장하는 것에 관해서는 많은 조언을 드릴 수는 없습니다. 어쩌면이 링크가 도움이 될 수 있습니다. 비주얼 매개 변수로 Polygon을 전달합니다. http://www.wpftutorial.net/BitmapFromVisual.html – Torsten
Torsten, 고마워요. –