Resizing window causes black strips

前端 未结 2 1667
感情败类
感情败类 2020-12-19 19:07

I have a form, which sets these styles in constructor:

this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.UserPaint, true);         


        
2条回答
  •  余生分开走
    2020-12-19 19:54

    I found that it is best not to do any custom rendering directly on the Form surface. Instead, put a docked PictureBox on the form, create Bitmap object that will be displayed in the PictureBox, draw everything onto that using the System.Drawing.Graphics.FromImage(Image) method.

    I used that method with a game loop to make a simple shooter game (Crimsonland-style) and got pretty good performance (with anti-aliased lines), above 100 FPS.

提交回复
热议问题