Silverlight 4 WriteableBitmap 到位图

发布于 2024-09-27 09:37:38 字数 247 浏览 1 评论 0原文

这是我的第一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦在夏天 2024-10-04 09:37:38

最后通过将 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.

时光沙漏 2024-10-04 09:37:38

我想确保我正确理解您的意思,您正在使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文