我想创建自己的
System.Drawing.Image
实现,但我总是得到 'Image' does not contain a constructor that takes 0 arguments
。 System.Drawing.Image
是一个抽象类。
public class ImageYUV : System.Drawing.Image
{
}
我确实研究了
Bitmap
的实施,但我没有找到解决方案......
谁能告诉我我错过了什么?
尽管
System.Drawing.Image
类被标记为 abstract
,但你无法从中派生出你自己的类。
它在其构造函数上使用 C# 7.2 中引入的
private protected
访问修饰符,以允许仅从位于同一程序集中的类进行派生 (System.Drawing.dll
)。
Image
类基本上是通过 unsafe
调用的 GDI+ 本机代码的 P/Invoke
包装器,它与内部 GDI+ 图像表示一起使用,因此从它派生并没有多大意义。