Bitmap类型的图像类和构造函数?
好吧,我不明白 Image 类怎么会有 Bitmap 类型的构造函数?我的意思是,我可以这样做:
Image sprite=new Bitmap(...)
为什么?是因为Bitmap是从Image派生出来的吗?
Well I do not understand how it comes that Image class has a constructor of Bitmap type? I mean, I can do:
Image sprite=new Bitmap(...)
Why? Its because Bitmap is derived from Image?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,因为
Image
是抽象的,但扩展Image
的Bitmap
不是抽象的。您可以轻松地让您的代码执行此操作:Image
之所以是抽象的,是因为它还可以表示非基于像素的图像。Yes, because
Image
is abstract, butBitmap
, which extendsImage
is not. You could just as easily have your code do this instead:The reason why
Image
is abstract is because it can also represent non-pixel-based images.嗯,是的,这就是 MSDN 所说的(假设 < code>System.Drawing 命名空间):
但它不是具有
Bitmap()
构造函数的Image
类。由于Bitmap
继承自Image
,因此Bitmap
的所有实例也是Image
的实例。Well, yeah, that's what MSDN says (assuming
System.Drawing
namespace):But it's not the
Image
class that has aBitmap()
constructor. SinceBitmap
inherits fromImage
, all instances ofBitmap
are also instances ofImage
.