Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative to System.Drawing.Bitmap in Silverlight which is compatible with WPF

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).

like image 781
TimothyP Avatar asked Jul 30 '10 13:07

TimothyP


2 Answers

System.Windows.Media.Imaging for WPF and Silverlight. This one shows how to work with it in memory: Silverlight 4.0: How to convert byte[] to image?

like image 151
Stan Avatar answered Nov 04 '22 22:11

Stan


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.

like image 4
AnthonyWJones Avatar answered Nov 05 '22 00:11

AnthonyWJones