请教同时熟悉C++和C#高手:C++中如何处理C#的byte[]类型
班小冰 2010-12-22 11:38:55 小弟是C#出身,目前正在学习VC(基于VS2008)。现在基于C#封装了Web Service中的一个方法:
byte[] ANZoomIn(double PressX,double Y)。该方法的作用是根据屏幕触发点坐标生成一张图片,然后将图片转换为C#的二进制的流byte[]返回。在WebService中C#的byte[]类型被Soap1.2描述为base64Binary,如下:
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ANZoomInResponse xmlns="http://tempuri.org/">
<ANZoomInResult>base64Binary</ANZoomInResult>
</ANZoomInResponse>
</soap12:Body>
</soap12:Envelope>
小弟现在基于C++开发了一个Winform的客户端程序,但不知道在C++如何将WebService的base64Binary类型的返回值解析为自己识别的类型,然后将该二进制流还原为一张图片,最后执行贴图操作
如果是C#端的Winform程序,解析比较简单,只需要以下三步操作即可:
byte[] buffer = MyService.ANInitialWebService(); //直接在C#中以byte[]接收WebService中函数的返回值
MemoryStream mStream = new MemoryStream(buffer); //定义内存流
Bitmap map = new Bitmap(mStream); //基于内存流得到图片Bitmap类型
还请大家不吝赐教,最好能给出相应的C++的实现代码,小弟的C++基础比较薄弱