كيفية تحويل الشكل من DirectX إلى GDI+ باستخدام C#

StackOverflow https://stackoverflow.com/questions/2146358

  •  23-09-2019
  •  | 
  •  

سؤال

أرسم الدائرة في C# باستخدام DirectX.I أود رسم الدائرة بنفس الأبعاد في C# باستخدام gdi.it يعني أنني أحب تحويل تلك الدائرة من DirectX إلى GDI. هل أي مساعدة في الجسم بالنسبة لي. تقديم الإجابة بالنسبة لي. كيف يمكنني القيام بذلك. هل أي خوارزمية متاحة لذلك ........ وأيضًا أعطي مدخلات مركز الدائرة (x ، y ) في هذه النقطة تنسيق. ولكن في GDI هو تنسيق بكسل. حتى كيف يمكنني تحويل نقاط DirectX إلى GDI+ Pixels

هل كانت مفيدة؟

المحلول

فيما يلي رابط من MSDN يقدم الرسومات والرسم في نماذج Windows. ومن المحتمل أنك ستحتاج إلى شيء مشابه لـ:

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

}

بعد ذلك قد ترغب في النظر في تقنيات التعويض المزدوج ، بعض الروابط:

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top