2010-01-27 121 views
1

我使用directx.i在c#中绘制圆形,就像使用GDI在c#中绘制具有相同尺寸的圆一样。这意味着我喜欢将该圆形从directx转换为GDI。是任何身体的帮助me.plz为我提供了答案,我可以做到这一点。是任何可用的算法........ 而且我给圆的中心输入是(x, y)以这种格式。但在gdi中它是像素格式。因此,如何将directx点转换为gdi +像素如何将形状从Directx转换为gdi +使用c#

+0

所以,就像澄清一样,你有X,Y坐标他的圈子的中心,你有半径吗?圆圈的中心是相关的,还是只是想要有相似的形状? – 2010-02-06 17:24:10

+0

你我有双格式的半径 – ratty 2010-02-08 04:33:47

+0

你想在哪绘制它?使用c的Windows面板中的 – 2010-02-08 05:18:21

回答

3

这是MSDN的一个链接,介绍Graphics and Drawing in Windows Forms。而且很可能,你将需要类似于:

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); 

} 

之后,你可能要考虑双缓冲技术,几个环节:

+0

这只是绘制gdi我不是问这个 – ratty 2010-02-09 06:49:03

+3

所以,你问香蕉,但不想要香蕉。我可以给你很多不是香蕉的东西... – 2010-02-09 13:50:05

+0

+1 Dynami:出色的工作! – IAbstract 2010-02-11 22:59:51