Wie erstellen WriteableBitmap von BitmapImage?

Konnte ich erstellen WriteableBitmap von Bilder in Assets.

Uri imageUri1 = new Uri("ms-appx:///Assets/sample1.jpg");
WriteableBitmap writeableBmp = await new WriteableBitmap(1, 1).FromContent(imageUri1);

aber, ich kann nicht WriteableBitmap-Bilder Verzeichnis,(ich bin mit WinRT XAML Toolkit)

//open image
StorageFolder picturesFolder = KnownFolders.PicturesLibrary;
StorageFile file = await picturesFolder.GetFileAsync("sample2.jpg");
var stream = await file.OpenReadAsync();

//create bitmap
BitmapImage bitmap2 = new BitmapImage();
bitmap2.SetSource();
bitmap2.SetSource(stream);

//create WriteableBitmap, but cannot
WriteableBitmap writeableBmp3 = 
    await WriteableBitmapFromBitmapImageExtension.FromBitmapImage(bitmap2);

Ist das richtig ?

InformationsquelleAutor hiroo | 2013-02-05

Schreibe einen Kommentar