C#如何从图片框中获取位图

bha*_*thi 8 c# bitmap picturebox bitmapimage

我在picturebox中有一个图像.我想将该图像作为位图.

我的一行代码是:

Bitmap default_image = (Bitmap)pictureBox5.Image.Clone();

但我得到的是:

default_image value=null;

谁能帮我.

Eva*_*ski 16

Bitmap default_image = new Bitmap(pictureBox5.Image);
Run Code Online (Sandbox Code Playgroud)

你永远不会实例化Bitmap这就是为什么null.

  • @MGZero:我的理解是它是null,因为你不能将Image对象强制转换为Bitmap. (2认同)