-1

can anyone give me a quick comparison what are pros and cons of System.Windows.Media.Imaging.WriteableBitmap compared to System.Drawing.Image?

Why I'm asking because I have an program/api where I can basically choose between which one I want to use.

I know that not both can bind to the same controls for instance, but I'm interested a bit more in terms whats "under the hood".

The api I want to use is for displaying "realtime"/"fast" images and therefore have a fps of about 20-30 (if this matters somehow for the comparison).

flor1an
  • 960
  • 3
  • 15
  • 33
  • So you're asking somebody to write, and run, a test for you to compare the runtime performance of the two classes? – 15ee8f99-57ff-4f92-890c-b56153 May 25 '17 at 15:15
  • 1
    No, I'm looking for best practices / experiences – flor1an May 25 '17 at 15:17
  • 3
    They are just wrappers for two unmanaged graphics libraries. Image wraps GDI+, a library that dates from ~1999. WriteableBitmap wraps WIC, the successor of GDI+. WIC has better error reporting and can tackle much bigger bitmaps. Using it correctly is however a lot harder, it does not have a Dispose() method. Realistically you need a WPF app to avoid memory usage problems, albeit that even then programmers [struggle with that problem](https://stackoverflow.com/questions/2860917/how-do-i-get-net-to-garbage-collect-aggressively). – Hans Passant May 25 '17 at 15:46

1 Answers1

1

Well in case you want to go low level (well its still c# not c++) but the writeable bitmap allows for locking of the bitmap data, to run some unsafe code against it (usually graphics stuff needs super fast dirty trick logic processing )

So if you plan to go low level, work with pointers and stride, then i would go for it. BTW you can create functions to exchange formats, if all you want to do is displaying an image, maybe rotate or flip it or thinking about displaying stream data into an an image i'd choose the other one.

user613326
  • 2,140
  • 9
  • 34
  • 63