我試圖實現一個Windows通用應用程序。我面臨將圖像原始數據(字節數組)轉換爲BitmapImage控件的一個問題。我不知道圖像原始數據的類型。我用下面的代碼,將圖像原始數據轉換爲Windows中的bitmapimage通用應用程序
private async Task<BitmapImage> ByteArrayToBitmapImage(byte[] byteArray)
{
var bitmapImage = new BitmapImage();
var stream = new InMemoryRandomAccessStream();
await stream.WriteAsync(byteArray.AsBuffer());
stream.Seek(0);
bitmapImage.SetSource(stream);
return bitmapImage;
}
圖像不顯示在窗口中。當我調試,發現的BitmapImage對象的身高&寬度爲0
如果有人知道這個解決方案,請幫我
我試了一下。但沒有希望..似乎BitmapImage對象的pixelheight&pixelWidth屬性爲零。 –
這裏的圖像原始數據不包含標題數據..這是問題。 –