是什么System.Drawing.Image对象和System.Drawing.Bitmap之间的区别? [英] What is the difference between System.Drawing.Image and System.Drawing.Bitmap?

查看:494
本文介绍了是什么System.Drawing.Image对象和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 and System.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 from Image:

System.Drawing.Bitmap : System.Drawing.Image
{ }

Image is an abstract 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 of Image.

这篇关于是什么System.Drawing.Image对象和System.Drawing.Bitmap之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆