views:

199

answers:

2

I'm trying to cross compile some libraries for WPF and Silverlight. Currently one of the libraries depends on System.Drawing.Bitmap which is not available in Silverlight.

It's a class that represents a device specific image format, and holds a reference to a Bitmap instance in order to display this image in a WPF application.

What could I use instead of the Bitmap class in order to hold a reference to an Image which I can display in both silverlight and wpf ? (cannot be file based, must be in memory).

+2  A: 

The closest you will get is the WriteableBitmap class but these classes a quite different between frameworks. If you are looking to create a common library to use in both your WPF and Silverlight applications you will probably need to create an abstract that your applications code to and then write two different implementations of the abstract.

If both chunks of code return something tha,t at least lexically, is a "WriteableBitmap" then you might be able to integrate that into common code.

Worth looking at for the Silverlight side of the implementation would be WriteableBitmapEx.

AnthonyWJones
I'll have a look :)
TimothyP
+4  A: 

System.Windows.Media.Imaging for WPF and Silverlight. This one shows how to work with it in memory: http://stackoverflow.com/questions/2445449/silverlight-4-0-how-to-convert-byte-to-image

WinnerWinnerChickenDinner
I'll have a look at this, thank you (+1)
TimothyP