Struct SaveProgress
- Namespace
- Egami
- Assembly
- Egami.dll
How far a save such as Save(string, WriterOptions?, IProgress<SaveProgress>?, CancellationToken) has come. A save reports once as it starts, then at most every 250 ms, then once more with IsFinal set.
public readonly record struct SaveProgress : IEquatable<SaveProgress>
- Implements
- Inherited Members
Examples
// Slow encoders (AVIF, JPEG XL, lossy WebP) report how far they have come: once as they start, at most every 250 ms,
// then once more with IsFinal. A canceled token stops the encode and deletes the half-written file.
Progress<SaveProgress> progress = new(p => Console.WriteLine($"{p.Fraction:P0} after {p.Elapsed.TotalSeconds:F1} s"));
image.Save("duck.avif", options: null, progress, cancellationToken);
Properties
BytesWritten
Gets how many bytes were written to the output, or 0 when it cannot seek (such as a pipe).
public long BytesWritten { get; init; }
Property Value
Elapsed
Gets the wall-clock time since the save started.
public TimeSpan Elapsed { get; init; }
Property Value
Fraction
Gets how much of the save is done, from 0 to 1, or null when the format's writer does not say (it then reports only as it starts and ends). Formats that encode the whole image at the end, such as AVIF, JPEG XL and lossy WebP, count their own work, not the rows handed to them. It never goes backwards, and the final report has 1.
public double? Fraction { get; init; }
Property Value
Frames
Gets how many frames of an animation were written; 0 for a still image until the final report, which has 1.
public int Frames { get; init; }
Property Value
IsFinal
Gets whether this is the last report: the save finished.
public bool IsFinal { get; init; }