11// Copyright (c) TensorStack. All rights reserved.
22// Licensed under the Apache 2.0 License.
3+ using System . Threading ;
4+ using System . Threading . Tasks ;
35using System . Windows . Media . Imaging ;
46using TensorStack . Common ;
57using TensorStack . Common . Tensor ;
@@ -9,8 +11,9 @@ namespace TensorStack.Image
911 /// <summary>
1012 /// ImageInput implementation with System.Windows.Media.Imaging.WriteableBitmap.
1113 /// </summary>
12- public class ImageInput : ImageTensor
14+ public class ImageInput : ImageInputBase
1315 {
16+ private readonly string _sourceFile ;
1417 private WriteableBitmap _image ;
1518
1619 /// <summary>
@@ -47,7 +50,10 @@ public ImageInput(BitmapSource image)
4750 /// </summary>
4851 /// <param name="filename">The filename.</param>
4952 public ImageInput ( string filename )
50- : this ( ImageService . Load ( filename ) ) { }
53+ : this ( ImageService . Load ( filename ) )
54+ {
55+ _sourceFile = filename ;
56+ }
5157
5258
5359 /// <summary>
@@ -69,17 +75,33 @@ public ImageInput(string filename, int width, int height, ResizeMode resizeMode
6975 /// </summary>
7076 public WriteableBitmap Image => _image ;
7177
78+ /// <summary>
79+ /// Gets the source Image filename.
80+ /// </summary>
81+ public override string SourceFile => _sourceFile ;
82+
7283
7384 /// <summary>
7485 /// Saves the image.
7586 /// </summary>
7687 /// <param name="filename">The filename.</param>
77- public void Save ( string filename )
88+ public override void Save ( string filename )
7889 {
7990 _image . Save ( filename ) ;
8091 }
8192
8293
94+ /// <summary>
95+ /// Save the Image to file
96+ /// </summary>
97+ /// <param name="filename">The filename.</param>
98+ /// <param name="cancellationToken">The cancellation token</param>
99+ public override Task SaveAsync ( string filename , CancellationToken cancellationToken = default )
100+ {
101+ return Task . Run ( ( ) => Save ( filename ) , cancellationToken ) ;
102+ }
103+
104+
83105 /// <summary>
84106 /// Called when Tensor data has changed
85107 /// </summary>
0 commit comments