Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将形状从Directx转换为gdi+;使用c#_C#_Directx_Gdi+ - Fatal编程技术网

如何将形状从Directx转换为gdi+;使用c#

如何将形状从Directx转换为gdi+;使用c#,c#,directx,gdi+,C#,Directx,Gdi+,我使用directx在c#中绘制圆。我喜欢使用GDI在c#中绘制尺寸相同的圆。这意味着我喜欢将该圆从directx转换为GDI。有人帮我吗?请告诉我答案。我该怎么做。有什么算法可以解决这个问题吗。。。。。。。。 我也给出了圆心的输入,在这个点格式中是(x,y)。但在gdi中是像素格式。那么我如何将directx点转换为gdi+像素呢。而且,您可能需要类似于: public Form1() { InitializeComponent(); this.Paint += new Pa

我使用directx在c#中绘制圆。我喜欢使用GDI在c#中绘制尺寸相同的圆。这意味着我喜欢将该圆从directx转换为GDI。有人帮我吗?请告诉我答案。我该怎么做。有什么算法可以解决这个问题吗。。。。。。。。
我也给出了圆心的输入,在这个点格式中是(x,y)。但在gdi中是像素格式。那么我如何将directx点转换为gdi+像素呢。而且,您可能需要类似于:

public Form1()
{
    InitializeComponent();

    this.Paint += new PaintEventHandler(Form1_Paint);

    // This works too
    //this.Paint += (_, args) => DrawCircle(args.Graphics);  
}

void Form1_Paint(object sender, PaintEventArgs e)
{
    DrawCircle(e.Graphics);
}

private void DrawCircle(Graphics g)
{
    int x = 0;
    int y = 0;
    int radius = 50;

    // The x,y coordinates here represent the upper left corner
    // so if you have the center coordinates (cenX, cenY), you will have to
    // substract radius from  both cenX and cenY in order to represent the 
    // upper left corner.

    // The width and height represents that of the bounding rectangle of the circle
    g.DrawEllipse(Pens.Black, x, y, radius * 2, radius * 2);

    // Use this instead if you need a filled circle
    //g.FillEllipse(Brushes.Black, x, y, radius * 2, radius * 2);

}
在这之后,您可能需要研究双缓冲技术,以下是几个链接:


作为澄清,你有圆心的X,Y坐标,你有半径吗?圆的中心是相关的,还是你只是想有一个相似的形状?是的,我有双格式的半径,你想在哪里画它?我在这里进行最后一个疯狂的拍摄。你真的想在Winforms C#面板控件中显示DirectX输出吗?不,我用C#在DirectX编码中创建圆圈,如何在gdi中绘制它我只需要转换这只是在gdi中绘制我不是在问这个,所以你要香蕉,但不要香蕉。我可以给你很多不是香蕉的东西。。。