private static async Task affectBitmapImageToNewDisplayablePhotoObject(StorageFile file, VideoDataStructure pds) { StorageItemThumbnail fileThumbnail = await file.GetThumbnailAsync(ThumbnailMode.SingleItem, 900); BitmapImage bitmapImage = new BitmapImage(); bitmapImage.SetSource(fileThumbnail); pds.Image = bitmapImage; }
private VideoDataStructure createNewDisplayableVideoObject(StorageFile file) { BitmapImage bi = new BitmapImage(new Uri(file.Path, UriKind.Absolute)); VideoDataStructure pds = new VideoDataStructure() { VideoData = new DataModel.VideoDataStructure() { AlbumId = albumInfo.Id, Latitude = albumInfo.Latitude, Longitude = albumInfo.Longitude, VideoPath = file.Path, ItemId = DateTime.Now.ToString() + file.Path }, Image = bi, VideoWidthHeight = Constants.HalfScreenHeight - 35, VideoWidth = (Constants.HalfScreenHeight - 35) * (Convert.ToDouble(bi.PixelWidth) / Convert.ToDouble(bi.PixelHeight)) }; return pds; }
private async Task<VideoDataStructure> saveNonLocalFileToLocalAndAddVideoToList(StorageFile storageFile) { VideoDataStructure 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 VideoDataStructure() { VideoData = new DataModel.VideoDataStructure() { AlbumId = albumInfo.Id, Latitude = albumInfo.Latitude, Longitude = albumInfo.Longitude, VideoPath = filePath, ItemId = DateTime.Now.ToString() + file.Path }, Image = bitmapImage, VideoWidthHeight = Constants.HalfScreenHeight - 35, VideoWidth = (Constants.HalfScreenHeight - 35) * (Convert.ToDouble(bitmapImage.PixelWidth) / Convert.ToDouble(bitmapImage.PixelHeight)) }; } catch (Exception exp) { //Constants.ShowWarningDialog(Constants.ResourceLoader.GetString("2FileLocalizationFailed") + "\n\r" + exp.Message); } return pds; }