gdi+ Graphics::DrawImage really slow~~

后端 未结 9 997
一个人的身影
一个人的身影 2020-12-13 10:48

I am using a GDI+ Graphic to draw a 4000*3000 image to screen, but it is really slow. It takes about 300ms. I wish it just occupy less than 10ms.

Bitmap *bit         


        
9条回答
  •  囚心锁ツ
    2020-12-13 11:36

    If you're using GDI+, the TextureBrush class is what you need for rendering images fast. I've written a couple of 2d games with it, getting around 30 FPS or so.

    I've never written .NET code in C++, so here's a C#-ish example:

    Bitmap bmp = new Bitmap(...)
    TextureBrush myBrush = new TextureBrush(bmp)
    
    private void Paint(object sender, PaintEventArgs e):
    {
        //Don't draw the bitmap directly. 
        //Only draw TextureBrush inside the Paint event.
        e.Graphics.FillRectangle(myBrush, ...)
    }
    

提交回复
热议问题