private static async Task affectBitmapImageToNewDisplayablePhotoObject(StorageFile file, PhotoDataStructure pds) { try { if(file == null || pds == null) return; StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 600); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); pds.Image = bitmapImage; } catch(Exception exp) { throw exp; } }
private PhotoDataStructure createNewDisplayablePhotoObject(StorageFile file) { PhotoDataStructure pds = new PhotoDataStructure() { PhotoData = new DataModel.PhotoDataStructure() { AlbumId = albumInfo.Id, Latitude = albumInfo.Latitude, Longitude = albumInfo.Longitude, ImagePath = file.Path, ItemId = DateTime.Now.ToString() + file.Path }, Image = new BitmapImage(new Uri(file.Path, UriKind.Absolute)), ImageWidthHeight = Constants.HalfScreenHeight - 30 }; return pds; }
private async Task<PhotoDataStructure> saveNonLocalFileToLocalAndAddPhotoToList(StorageFile storageFile) { PhotoDataStructure pds = null; try { IRandomAccessStream iras = await storageFile.OpenReadAsync(); Windows.Storage.Streams.Buffer MyBuffer = new Windows.Storage.Streams.Buffer(Convert.ToUInt32(iras.Size)); IBuffer iBuf = await iras.ReadAsync(MyBuffer, MyBuffer.Capacity, InputStreamOptions.None); string filename = DateTime.Now.ToString().Replace(":", "").Replace("/", "_").Replace("\\", "_").Replace(".", "").Replace("\"", "") + "lifemapcover" + storageFile.Name; string filePath = await Helper.SaveImages(iBuf, filename); StorageFile file = await Windows.Storage.StorageFile.GetFileFromPathAsync(filePath); StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 600); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); pds = new PhotoDataStructure() { PhotoData = new DataModel.PhotoDataStructure() { AlbumId = albumInfo.Id, Latitude = albumInfo.Latitude, Longitude = albumInfo.Longitude, ImagePath = filePath, ItemId = DateTime.Now.ToString() + file.Path }, Image = bitmapImage, ImageWidthHeight = Constants.HalfScreenHeight - 30 }; } catch { //Constants.ShowWarningDialog(Constants.ResourceLoader.GetString("2FileLocalizationFailed") + "\n\r" + exp.Message); } return pds; }