我當前正試圖將我從RenderTargetBitmap獲得的IBuffer轉換爲Base64String,反之亦然。我在Silverlight中成功地做了這樣的事情,但現在在Windows運行時,有很多庫缺失,我不知道現在要做什麼。Windows Phone運行時:RendertargetBitmap/IBuffer到Base64,反之亦然
下面是我最新的示例代碼,它沒有發生任何錯誤,但是當我嘗試運行它時,它會讓我的應用程序崩潰。有什麼建議麼?
在此先感謝
var bitmap = new RenderTargetBitmap();
await bitmap.RenderAsync(drawingPanel);
IBuffer pixel = await bitmap.GetPixelsAsync();
String b64 = CryptographicBuffer.EncodeToBase64String(pixel);
IBuffer backpixel = CryptographicBuffer.DecodeFromBase64String(b64);
WriteableBitmap wb = new WriteableBitmap(bitmap.PixelWidth, bitmap.PixelHeight);
wb.SetSource(backpixel.AsStream().AsRandomAccessStream());
imageBox.Source = wb;
imageBox是一個XAML元素來檢查,如果轉換成功
編輯:我沒有得到任何例外情況與此代碼,應用程序只是凍結
你在哪條線上得到異常 –
沒有例外。它的字面意思就是沒有任何反應。我步入代碼,所有變量都已填充,但最終產品沒有任何問題 – glace
編輯了問題 – glace