static public async Task <BlueFrameImage> CreateInstanceAsync(SoftwareBitmap softwareBitmap) { BlueFrameImage bfi = new BlueFrameImage(softwareBitmap); bfi.mSource = new SoftwareBitmapSource(); await bfi.mSource.SetBitmapAsync(softwareBitmap); return(bfi); }
private async void LoadButton_Click(object sender, RoutedEventArgs e) { FileOpenPicker fileOpenPicker = new FileOpenPicker(); fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary; fileOpenPicker.FileTypeFilter.Add(".png"); fileOpenPicker.ViewMode = PickerViewMode.Thumbnail; var inputFile = await fileOpenPicker.PickSingleFileAsync(); if (inputFile == null) { return; } SoftwareBitmap softwareBitmap; using (IRandomAccessStream stream = await inputFile.OpenAsync(FileAccessMode.Read)) { // Create the decoder from the stream BitmapDecoder decoder = await BitmapDecoder.CreateAsync(BitmapDecoder.PngDecoderId, stream); // Get the SoftwareBitmap representation of the file softwareBitmap = await decoder.GetSoftwareBitmapAsync(); } if (softwareBitmap.BitmapPixelFormat != BitmapPixelFormat.Bgra8 || softwareBitmap.BitmapAlphaMode == BitmapAlphaMode.Straight) { softwareBitmap = SoftwareBitmap.Convert(softwareBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Premultiplied); } gBlueFrameImage = await BlueFrameImage.CreateInstanceAsync(softwareBitmap); DeviceImage.Source = gBlueFrameImage.GetImageSource(); LoadPathTextBlock.Text = inputFile.Path; }