如何在智能设备应用程序(C#)中将object[]转换为图像?
我正在用 C# 开发智能设备应用程序。我正在调用网络服务。 Web 服务方法返回 Google 地图。该方法的返回类型是object[]。对象[]包含字节格式的图像。 Google 地图图像的肥皂响应是 xsi:type="xs:base64Binary"。在对象中我没有得到字符串。在对象中我得到字节数组。 所以我在以下变量中捕获网络服务的响应。
对象[] GoogleMap;
调试后我可以看到在自动中我得到的结果如下。
名称: 价值: 谷歌地图{对象[1]} [0] {byte[23570]}
我需要在我的应用程序中显示实际图像。我需要执行什么类型的转换才能显示图像。请确保 .net 框架的所有核心功能不适用于 .net 紧凑框架。您能给我提供可以解决上述问题的代码或任何链接吗?
I am developing smart device application in C#. In that I am calling the web services. The web service method return Google map. The return type of the method is object []. The object [] contains the image in byte format. The soap response for Google Maps image is xsi:type="xs:base64Binary". In object I am not getting the string. In object I am getting the byte array.
So I am catching the response of web service in following variable.
object [] GoogleMap;
After debugging I can see that in auto I am getting the result as follows.
Name: Value:
GoogleMap {object[1]}
[0] {byte[23570]}
I need to display the actual image in my application. What type of casting I need to do to display the image.Please make sure that all the core functions of .net framework does not work with .net compact framework. Can you provide me the code or any link through which I can resolve the above issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您需要取出字节数组:
然后创建一个 < code>MemoryStream 围绕它:
现在从流创建一个
Bitmap
:请注意,您不应该关闭
MemoryStream
> - 当您处理Image
时,这将关闭流。(编辑:从
Image.FromStream
更改为调用Bitmap
构造函数,因为Image.FromStream
似乎不在 CF 中。)First you need to get the byte array out:
Then create a
MemoryStream
around it:Now create a
Bitmap
from the stream:Note that you should not close the
MemoryStream
- when you dispose of theImage
, that will close the stream.(EDIT: Changed from
Image.FromStream
to calling theBitmap
constructor asImage.FromStream
appears not to be in the CF.)