What happens is that I have an image captured from a PC folder
//Capturar imagen
//https://docs.microsoft.com/es-es/windows/uwp/files/quickstart-using-file-and-folder-pickers
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
picker.FileTypeFilter.Add(".png");
Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
if (file == null)
return;
After capturing it I show it in a <Image/>
by means of Binding to the ViewModel from the XAML
<Image Source="{Binding CurrentImage, Mode=TwoWay}" Width="150" Height="150" HorizontalAlignment="Left"/>
and this is the code of the View Model, I believe the property to which I will make Binding:
public ImageSource CurrentImage { get { return currentImage; } set { Set(ref currentImage, value); } }
private ImageSource currentImage;
and within the method goes like this:
//Mostrar en <Image/>
//https://stackoverflow.com/questions/34214553/binding-image-source-to-page
var bitmap = new BitmapImage();
await bitmap.SetSourceAsync(await file.OpenReadAsync());
this.CurrentImage = bitmap;
Now what I need is Serialize it in bytes to save it in the database and I could not
I saw this video and it does not work for me, the Image property generates an error, it does not appear, I do not know if I have to import any libraries: link
also look at this Blog and it does not work for me, it does not let me import System.Drawing.Image
: link
and I do not know how to do serialization in UWP with C #