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 ?
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 ?
Am not sure what you mean difference?
System.Drawing.Image
is the base class forSystem.Drawing.Bitmap
.System.Drawing.Image
is abstract class as well, so you can't create instance of it. You'll have to create instance ofSystem.Drawing.Bitmap
only.Image.FromFile
, Image.BlahBlah... returns you instance ofBitmap
only.As the MSDN documentation clearly states about
System.Drawing.Image
:So you cannot compare them. The
System.Drawing.Bitmap
class is a concrete implementation of the abstractSystem.Drawing.Image
class.Bitmap
inherits fromImage
:Image
is an abstract class, this means:Bitmap
is a sealed class, this means:See the following:
This is because
Image
is not meant to be used this way. It just provides functionality for theBitmap
class.Thus use
Bitmap
when dealing with pixelated images, like jpeg, png, bmp, etc.If you expect no specific type of image in your method and the methods of
Image
are sufficient, use the more generalImage
as parameter type. This method will then accept other classes inheriting fromImage
as well, for exampleMetafile
.Image is a base abstract class representing a raster image. Bitmap is one implementation of this abstract class based on GDI+.