Silverlight 4 WriteableBitmap 到位图
这是我的第一个 Silverlight 应用程序,也是我第一次接触 C#。我有一个 C# 类库,可以使用 COM 从 Silverlight 访问它。 C# 库有一个将 Bitmap 作为参数的方法,但是从我看来,Silverlight 只有一个 WritableBitmap。有没有办法在 Silverlight 中将 WritableBitmap 转换为位图?我读过的其他一些答案给出了用于转换的函数,但这些函数都返回一个位图,这在我尝试构建时显然会引发错误。有人可以帮忙吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最后通过将 WritableBitmap 转换为字节数组,传递它,然后在另一侧再次构建位图来使其工作。
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.
我想确保我正确理解您的意思,您正在使用 Silverlight 与使用 COM 的 C# Windows 库进行对话,C# libraru 正在使用 Silverlight 没有任何引用的类,对吗?
如果是这种情况,我会立即考虑使用 WPF 而不是 Silverlight,你能做到吗? Bitmap 类实际上只是 GDI+ 图像的包装器,这就是您无法真正在 Silverlight 中使用它的原因。
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.