Come convertire una forma da DirectX per GDI + utilizzando c #
Domanda
I disegnare il cerchio in C # utilizzando directx.i desidera richiamare il cerchio con stesse dimensioni in C # utilizzando GDI.It significa mi piace per convertire quel cerchio da directx a GDI. E 'tutto l'aiuto del corpo per me.plz fornire la risposta per me.how posso fare it.Is qualsiasi algoritmo disponibile per tale ........ E anche i dare l'input per il centro del cerchio è (x, y) in questo punto format.but in gdi è formato pixel .so come posso convertire i punti DirectX per GDI + pixel
Soluzione
Ecco un link da MSDN che introduce Grafica e Disegno in Windows Form . Ed è probabile che sarà necessario qualcosa di simile a:
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);
}
Dopo di che si potrebbe voler esaminare le tecniche di doppio buffering, alcuni link: