简体   繁体   English

如何在Silverlight4中将BitmapImage转换为字节数组?

[英]How to convert BitmapImage into byte array in silverlight4?

I am trying to convert the BitmapImage into byte array, but not getting the exact solution. 我试图将BitmapImage转换为字节数组,但没有得到确切的解决方案。 The Image.Save() method is not available in Silverlight Library. Silverlight库中没有Image.Save()方法。 How to fix this? 如何解决这个问题?

if you image source is in the project you can use this.. 如果您的图像源在项目中,您可以使用此..

var uri = new Uri("/ReferencedAssembly;component/default.png", UriKind.Relative);
var streamInfo = System.Windows.Application.GetResourceStream(uri);
var stream = streamInfo.Stream; 

convert the stream to bytes array.. 将流转换为bytes数组..

if image is one some other location 如果图像是一个其他位置

Using httpwebrequest to get image from website to byte[] 使用httpwebrequest将图像从网站获取到byte []

Regards 问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM