This is my first Silverlight app and my first go at C#. I have a C# class library that I access from Silverlight using COM. The C# library has a method that takes a Bitmap as an argument, however from what I can see Silverlight only has a WritableBitmap. Is there a way to convert a WritableBitmap to a Bitmap in Silverlight? Some other answers I have read give functions for the conversion, but the functions all return a Bitmap, which obviously throws an error when I try and build. Can anyone help?
A:
I want to make sure I am understanding you correctly, you are using Silverlight to talk to a C# windows library using COM, the c# libraru is using classes that Silverlight does not have any references to, correct?
If this is the case, I would immediately look into using WPF instead of Silverlight, can you do this? The Bitmap class is really just a wrapper for a GDI+ image, which is why you wont really be able to use it in Silverlight.
Mark
2010-10-13 09:57:12
Hi Mark. You are correct, Silverlight does not have access to the classes I need to use. I would like to stay with Silverlight if possible to maintain cross platform compatibility. The COM solution is only temporary for the proof of concept, as obviously it locks everything to Windows. Someone at work suggested passing the bitmap through as a pixel array and then rebuilding it on the library side.
Snowwire
2010-10-13 20:28:47
A:
Finally got it working by converting the WritableBitmap into a byte array, passing it through and then building the bitmap again on the other side.
Snowwire
2010-10-15 06:31:02