我想在我的Windows 8.1应用中将BitmapImage转换为base64string。 代码:
protected void UpdateSignatureAsync(BitmapImage bitmapImage, string fileName, long vehicleInsRecID)
{
WriteableBitmap writimage = new WriteableBitmap(bitmapImage.PixelWidth, bitmapImage.PixelHeight);
using (MemoryStream ms = new MemoryStream())
{
WriteableBitmapExtensions.FromStream(writimage, ms);
Stream s1 = writimage.PixelBuffer.AsStream();
s1.CopyTo(ms);
writimage.PixelBuffer.AsStream();
var ic = new ImageCapture
{
ImageBinary = Convert.ToBase64String(ms.ToArray()),/// this line
CaseServiceRecId = vehicleInsRecID,
FileName = fileName
};
await UpdateImageAsync(ic);
}
答案 0 :(得分:0)
我对您的问题没有确切的答案,但如果您的StorageFile
是图片,那么您可以使用{{将此图片转换为Base64
字符串1}}以下类中的方法:
GetBase64FromImageFile