本文讨论如何在 C# 中模糊 image。它涵盖了系统配置、过程和可运行的代码片段,以在 C# 中模糊图片**。您可以减少或增加任何图像格式的模糊强度,例如 PNG、BMP、JPG 等。
在 C# 中模糊图像的步骤
- 使用 NuGet 包管理器将系统设置为与 Aspose.Imaging for .NET 一起使用以模糊图像
- 使用 Image 类加载输入图像
- 使用 Filter 方法应用图像模糊效果
- 使用 Save 方法写入模糊图像
这些步骤演示了在 C# 中为照片添加模糊的工作流程。第一步,根据您的要求从磁盘或流中访问输入图像。随后,模糊图像并将其导出为您喜欢的图像格式。
C# 中模糊图像的代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Aspose.Imaging; | |
using System; | |
class Program | |
{ | |
static void Main(string[] args) // Blur image in C# | |
{ | |
new License().SetLicense("License.lic"); | |
// Load the image | |
using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load("input.png")) | |
{ | |
// Convert the image into RasterImage | |
Aspose.Imaging.RasterImage rasterImage = (Aspose.Imaging.RasterImage)image; | |
// Apply blur effect | |
rasterImage.Filter(rasterImage.Bounds, new Aspose.Imaging.ImageFilters.FilterOptions.GaussianBlurFilterOptions(5, 5)); | |
// Save blurred image | |
rasterImage.Save("output.png"); | |
} | |
Console.WriteLine("Image Blurred successfully"); | |
} | |
} |
此代码示例是在 C#* 中为图片添加*模糊效果的简单解决方案。它与图像类一起访问源图像,然后在 Filter 方法中指定模糊半径和 sigma 值。最后,将模糊图像导出到输出文件。
在本文中,我们学习了在 C# 中模糊照片。另外,如果您想翻转图像,请参阅如何C# 中的翻转图像的文章。