Kas*_*Kas 13 c# drawing image bitmap winforms
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 ?
为什么要使用System.Drawing.Bitmap而不是System.Drawing.Image?
And*_*ndy 13
Bitmap继承自Image:
System.Drawing.Bitmap : System.Drawing.Image
{ }
Run Code Online (Sandbox Code Playgroud)
Image 是一个抽象类,这意味着:
abstract修饰符指示正在修改的事物具有缺失或不完整的实现.
Bitmap 是一个密封的类,这意味着:
应用于类时,sealed修饰符会阻止其他类继承它.
请参阅以下内容:
Bitmap bmp = new Bitmap(filename); // Works
Image img = new Image(); // The compiler says: "Cannot access internal constructer 'Image' here.
Run Code Online (Sandbox Code Playgroud)
这是因为Image不打算以这种方式使用.它只是为Bitmap类提供功能.
因此总是使用Bitmap而不是Image.