10

I was wondering what the difference is between Image, Bitmap and BitmapImage in WPF & C#.

Can someone help me out?

Mark A. Donohoe
  • 28,442
  • 25
  • 137
  • 286
Tom Kerkhove
  • 2,151
  • 5
  • 26
  • 42

2 Answers2

17

Image is a base abstract class representing images in GDI+. Bitmap is a concrete implementation of this base class.

BitmapImage is a way to represent an image in a vector based GUI engine like WPF and Silverlight. Contrary to a Bitmap, it is not based on GDI+. It is based on the Windows Imaging Component.

There are ways to load a BitmapImage from a Bitmap.

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
13

WinForms/GDI+ uses the abstract class System.Drawing.Image and its implementation Bitmap.

WPF uses the abstract class System.Windows.Media.ImageSource (and BitmapSource) and its implementation BitmapImage.

WPF also has a control named Image, which is a FrameworkElement that contains and displays an ImageSource.

It took me a while to untangle that mess of terminology...

Mark
  • 374
  • 4
  • 9
  • I am very new to all these topics - C#, WPF, and WinForms. It is my understanding that WPF is potentially faster than WinForms because it accesses hardware for rendering, whereas WinForms uses GDI/GDI+. When using WPF, as long as you are using the FrameworkElement version of the Image class, it should be hardware accelerated, correct? Whereas if you were to use the System.Drawing.Image class within WPF, it would be GDI/GDI+? I had been trying to avoid the Image class in WPF because I thought it was all GDI/GDI+, not realizing that WPF had it's own Image class that was, I assume, faster? – user613832 May 02 '23 at 17:26