Class UnsupportedFormatException
- Namespace
- Egami
- Assembly
- Egami.dll
Thrown when no registered format matches the data, or the matching format cannot read or write.
public sealed class UnsupportedFormatException : EgamiException, ISerializable
- Inheritance
-
UnsupportedFormatException
- Implements
- Inherited Members
Examples
EgamiContext strict = EgamiContext.Default with
{
Limits = SafetyLimits.Default with { MaxPixels = 25_000_000, MaxTotalBytes = 256L * 1024 * 1024 },
};
try
{
// Read the header first: cheap, and it rejects what you do not want before any pixel memory is used.
RasterInfo info = Raster.Probe(upload, strict);
if (info.Width > 8000 || info.Height > 8000)
{
throw new InvalidDataException("Too large.");
}
using Raster image = Raster.Load(upload, strict, new ReaderOptions { Recovery = RecoveryMode.Strict });
Console.WriteLine($"{info.Format.Name} {image.Width} × {image.Height}");
}
catch (UnsupportedFormatException)
{
Console.WriteLine("Not an image format we accept.");
}
catch (LimitExceededException e)
{
Console.WriteLine($"Over the {e.LimitName} limit.");
}
catch (CorruptDataException e)
{
Console.WriteLine($"Damaged at byte {e.Offset}.");
}
Constructors
UnsupportedFormatException(string, Exception?)
Initializes a new instance of the UnsupportedFormatException class.
public UnsupportedFormatException(string message, Exception? innerException = null)