使GDI绘制更高效的C#

时间:2015-06-13 16:33:42

标签: c# gdi

目前我的代码占用了大约10%的CPU电量。如何使其更高效,更少闪烁? 代码:

private void timer1_Tick(object sender, EventArgs e)
{
    DrawLocal();
    Thread.Sleep(17);
    pictureBox1.Invalidate();
}

private void DrawLocal()
{
    int localReadX = ReadAddress("hl2", "client.dll+0xBFFF00 364 0");
    int localReadY = ReadAddress("hl2", "client.dll+0xBFFF00 368 0");

    byte[] bytesOflocalX = BitConverter.GetBytes(localReadX);//converts to float
    byte[] bytesOflocalY = BitConverter.GetBytes(localReadY);//converts to float

    float localX = BitConverter.ToSingle(bytesOflocalX, 0)/10;//converts to float
    float localY = BitConverter.ToSingle(bytesOflocalY, 0)/10;//converts to float

    Graphics localP = pictureBox1.CreateGraphics();
    localP.FillRectangle(new SolidBrush(Color.Red), localX, localY, 5, 5);

    Graphics localName = pictureBox1.CreateGraphics();
    localName.DrawString("  local", new Font("Arial", 7), new SolidBrush(Color.Red), localX, localY);
}

1 个答案:

答案 0 :(得分:0)

以上评论如下所示:

password-change-done