public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode) { if (StorageItem is StorageFile File) { return(await File.OpenAsync(Mode)); } else { return(await FileRandomAccessStream.OpenAsync(Path, Mode)); } }
public static async Task <BitmapImage> LoadImageAsync(string imagePath) { using (IRandomAccessStream fileStream = await FileRandomAccessStream.OpenAsync(imagePath, Windows.Storage.FileAccessMode.Read)) { // Set the image source to the selected bitmap BitmapImage bitmapImage = new BitmapImage(); bitmapImage.DecodePixelWidth = 500; //match the target Image.Width, not shown await bitmapImage.SetSourceAsync(fileStream); System.Diagnostics.Debug.WriteLine(imagePath + " finished loading thumb!"); return(bitmapImage); //Image = bitmapImage; //System.Diagnostics.Debug.WriteLine(title + " finished loading thumb!"); } }
/// <summary> /// Fixes 3D printing inputFile and returns path to fixed file. /// </summary> /// <param name="inputFile">The absolute path to the file to be fixed.</param> /// <param name="outputFile">The absolute path to the output fixed file. Defaults to appending '_fixed' to the InputFile file name.</param> /// <returns>The absolute path to the fixed file.</returns> public async Task <string> FixAsync(string inputFile, string outputFile = "") { InputFile = inputFile; OutputFile = outputFile; var package = new Printing3D3MFPackage(); using var stream = await FileRandomAccessStream.OpenAsync(InputFile, FileAccessMode.ReadWrite); var model = await package.LoadModelFromPackageAsync(stream); await model.RepairAsync(); await package.SaveModelToPackageAsync(model); using var outstream = WindowsRuntimeStreamExtensions.AsStream(await package.SaveAsync()); using var outfile = File.Create(OutputFile); outstream.Seek(0, SeekOrigin.Begin); outstream.CopyTo(outfile); return(OutputFile); }
public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode) { return(await FileRandomAccessStream.OpenAsync(Path, Mode, StorageOpenOptions.AllowReadersAndWriters, FileOpenDisposition.OpenExisting)); }
public virtual async Task <IRandomAccessStream> GetRandomAccessStreamFromFileAsync(FileAccessMode Mode) { return(await FileRandomAccessStream.OpenAsync(Path, Mode)); }