public static void Save(this Image bitmap, IFileSystem fileSystem, UPath path) { var extension = path.GetExtensionWithDot(); IImageEncoder format; switch (extension) { case ".png": format = new PngEncoder(); break; default: throw new NotSupportedException(); } using var fileStream = fileSystem.CreateFile(path); bitmap.Save(fileStream, format); }
public static void Save(this System.Drawing.Bitmap bitmap, IFileSystem fileSystem, UPath path) { var extension = path.GetExtensionWithDot(); ImageFormat format; switch (extension) { case ".png": format = ImageFormat.Png; break; default: throw new NotSupportedException(); } using (var fileStream = fileSystem.CreateFile(path)) { bitmap.Save(fileStream, format); } }