加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – System.Drawing.Image和System.Drawing.Bitmap有什么区别

发布时间:2020-12-15 04:00:01 所属栏目:百科 来源:网络整理
导读:我感到困惑System.Drawing. Image和System.Drawing.Bitmap之间的区别是什么 有人可以解释这两种类型的主要区别吗? 为什么要使用System.Drawing.Bitmap而不是System.Drawing.Image? 解决方法 位图继承自Image: System.Drawing.Bitmap : System.Drawing.Ima
我感到困惑System.Drawing. Image和System.Drawing.Bitmap之间的区别是什么

有人可以解释这两种类型的主要区别吗?

为什么要使用System.Drawing.Bitmap而不是System.Drawing.Image?

解决方法

位图继承自Image:
System.Drawing.Bitmap : System.Drawing.Image
{ }

图像是一个抽象类,这意味着:

The abstract modifier indicates that the thing being modified has a missing or incomplete implementation.

位图是一个密封类,这意味着:

When applied to a class,the sealed modifier prevents other classes from inheriting from it.

请参阅以下内容:

Bitmap bmp = new Bitmap(filename); // Works
Image img = new Image(); // The compiler says: "Cannot access internal constructer 'Image' here.

这是因为Image不是以这种方式使用的.
它只为Bitmap类提供功能.

因此总是使用Bitmap而不是Image.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读