Right way to dispose Image/Bitmap and PictureBox

前端 未结 3 1974
慢半拍i
慢半拍i 2020-11-27 18:14

I am trying to develop a Windows Mobile 6 (in WF/C#) application. There is only one form and on the form there is only a PictureBox object. On it I draw all desired controls

3条回答
  •  星月不相逢
    2020-11-27 18:28

    You can get an Bitmap object from your controller and then assign it to image property of PictureBox. You should also dispose the current image of PictureBox to release the resource.

     var bmp = controller.GetBitmap();
     pictureBox1.Image.Dispose(); // this releases bitmap resources, required
     pictureBox1.Image = bmp;
    

提交回复
热议问题