Silverlight 中 System.Drawing.Bitmap 的替代方案,与 WPF 兼容
我正在尝试交叉编译 WPF 和 Silverlight 的一些库。 目前,其中一个库依赖于 System.Drawing.Bitmap,但在 Silverlight 中不可用。
它是一个代表设备特定图像格式的类, 并保存对 Bitmap 实例的引用以显示该图像 在 WPF 应用程序中。
我可以使用什么来代替 Bitmap 类来保存引用 到一个可以在 silverlight 和 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).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WPF 的 System.Windows.Media.Imaging 和 Silverlight。这个展示了如何在内存中使用它:Silverlight 4.0:如何将byte[]转换为图像?
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?
您将获得的最接近的是
WriteableBitmap
类,但这些类在框架之间有很大不同。如果您希望创建一个在 WPF 和 Silverlight 应用程序中使用的通用库,您可能需要创建一个应用程序编码的抽象,然后编写该抽象的两个不同实现。如果两个代码块都返回至少在词法上是“WriteableBitmap”的东西,那么您也许可以将其集成到通用代码中。
对于 Silverlight 方面的实现,值得关注的是 WriteableBitmapEx。
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.