是什么System.Drawing.Image对象和System.Drawing.Bitmap之间的区别? [英] What is the difference between System.Drawing.Image and System.Drawing.Bitmap?
问题描述
我很困惑什么是为System.Drawing.Image
和 System.Drawing.Bitmap
有人能解释这两种类型之间的主要区别?
以及为什么使用System.Drawing.Bitmap,而不是为System.Drawing.Image?
位图
从继承图片
:
System.Drawing.Bitmap:为System.Drawing.Image
{}
图片
是摘要
类,这意味着:
摘要修饰符指示要修改的东西有缺失或不完整的实现。
块引用>
位图
是一个密封类,这意味着:
当从它继承应用于类,sealed修饰符prevents其他类。
块引用>请参阅以下内容:
BMP位图=新位图(文件名); //作品
图片IMG =新的图像(); //编译器说:不能访问内部建筑工图像在这里。这是因为图像并不意味着使用这种方式!
它只是提供了位图
类的功能。所以,总是用
位图
而不是图片
。I am confused what's the different between
System.Drawing.Image
andSystem.Drawing.Bitmap
Can someone explain the major difference between those two types ?
And Why to use System.Drawing.Bitmap instead of System.Drawing.Image ?
解决方案
Bitmap
inherits fromImage
:System.Drawing.Bitmap : System.Drawing.Image { }
Image
is anabstract
class, this means:The abstract modifier indicates that the thing being modified has a missing or incomplete implementation.
Bitmap
is a sealed class, this means:When applied to a class, the sealed modifier prevents other classes from inheriting from it.
See the following:
Bitmap bmp = new Bitmap(filename); // Works Image img = new Image(); // The compiler says: "Cannot access internal constructer 'Image' here.
This is because Image is not meant to use it this way! It just provides functionality for the
Bitmap
class.So always use
Bitmap
instead ofImage
.这篇关于是什么System.Drawing.Image对象和System.Drawing.Bitmap之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!