【发布时间】:2014-02-07 08:23:37
【问题描述】:
说,我不知道这个 Base64 图像字符串的图像文件扩展名 从网络服务返回。
如何为 WinRT 处理这些?
将 Base64 字符串转换为图像后使用哪种类型的图像文件扩展名?
如何将这个base64图片字符串转换成图片?
使用 WebService 检索数据;
foreach( var ws_item in Results)
{
InsertItems(ws_item.Picture , ws_item.No, ws_item.Description .... )
}
void InsertItems( string pictureB64String ,..... )
{
//-- for image :
string _strPicture = PictureB64String;
//-- convert this base64 string into image and store in a Folder call ImagesFolder
ConvertBase64ToImage(_strPicture )
}
void ConvertBase64ToImage(string strPic)
{
}
【问题讨论】:
-
嗯,您可以尝试的一件事是将图像加载到
BitmapDecoder(应该能够处理几乎任何类型),然后将其编码为您想要的任何类型的文件。 -
这是来自网络服务的 Base64 字符串。如果您能告诉我如何完成这项任务,将不胜感激。
-
我不会为你做,但我会描述步骤。首先,查看the BitmapDecoder class。注意静态
CreateAsync方法。如果您阅读不接受Guid的方法,您会注意到它会自动选择正确的解码器。然后你需要做的是将base64string转换成IRandomAccessStream。我可能会使用内置的 Windows 运行时互操作扩展和CryptographicBuffer.CreateFromBase64String来做到这一点。
标签: c# base64 winrt-xaml