There is such a script (draws a triangle on the given coordinates and inserts it into the image) -
int[] xPoints = new int[] { Convert.ToInt32(AX), Convert.ToInt32(BX), Convert.ToInt32(CX) }; int[] yPoints = new int[] { Convert.ToInt32(AY), Convert.ToInt32(BY), Convert.ToInt32(CY) }; int xMin = 0; int yMin = 0; if(xPoints.Min() < 0) { xMin = xPoints.Min(); } if(yPoints.Min() < 0) { yMin = yPoints.Min(); } int height = (yPoints.Max() + (-yMin)) * 100; int width = (xPoints.Max() + (-xMin)) * 100;//задаю границы и увеличиваю размеры изображения(что бы не было 6x3 пикселя) Image myImage = new Image(); DrawingVisual drawingVisual = new DrawingVisual(); DrawingContext drawingContext = drawingVisual.RenderOpen(); drawingContext.DrawLine(new Pen(Brushes.Green, 1), new Point(CX, CY ), new Point(BX , BY )); drawingContext.DrawLine(new Pen(Brushes.Black, 1), new Point(CX, CY ), new Point(AX , AY )); drawingContext.DrawLine(new Pen(Brushes.Red, 1), new Point(AX * 300, AY * 300), new Point(BX * 300, BY * 300)); drawingContext.Close(); RenderTargetBitmap bmp = new RenderTargetBitmap(width, height, 100, 100, PixelFormats.Pbgra32); bmp.Render(drawingVisual); myImage.Source = bmp; MainCanvas.Children.Add(myImage); using (FileStream stream = new FileStream("Sample.png", FileMode.Create)) { PngBitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(stream); } I draw the lines and that's what happens - 
Why is this so? What do you need to multiply x, y (when creating a Point) so that the triangle fits exactly into its borders? And it was universal, that is, if I change the coordinate values, everything will also work fine. For some reason, the CB line is not drawn. I suspect that it is on the border of the image. If I make an beyond the size of the brush (2000), then this line will occupy the entire image, and if less, then it is not drawn at all.