Crop Images in C#

对于开发人员想要在 .NET 中实施 有效的图像挖掘技术, $ 99 Aspose.Imaging Image Cropper Plugin 是一个强大而易于使用的解决方案. 这个多元化的插件允许您提取图像的重要部分或重定向到各种文档格式和社交媒体尺寸. 凭借广泛的支持 RasterImage 类和多格式的兼容性,Aspose.Imaging 在您的 .NET 应用中简化复杂的图像编辑任务。

在本文中,我们将探讨如何在C#中种植图像,重点是两个主要方法:基于转值的种植和使用直角部分的种植。

主题 覆盖

  • C# API 用于图像挖掘
  • 使用转值的植物图像
  • 使用直角的植物图像

C# API for Image Cropping

是的 Aspose.Imaging 为 .NET 图书馆提供全面的图像操纵功能,包括精确的挖掘和对比 图形挖矿 .NET 库 对于流行的格式,如 JPEG、PNG、BMP 和 TIFF. 您可以轻松地通过 NuGet 安装 API 或下载集成文件,以便直接融入:

PM> Install-Package Aspose.Imaging

如何在C#中种植图像

Aspose.Imaging for .NET 提供两种有效的方法来收获图像: crop image 与 shift 值和 crop image 使用定义的直角。

种植图像与转值在 C# {# 种植图像与转值}

要在 C# 中使用转值种植图像,请遵循以下步骤:

下面是一个代码样本,展示如何在C#中种植图像:

// Load the image to be cropped.
using (RasterImage rasterImage = (RasterImage)Image.Load("image.png"))
{
// Before cropping, the image should be cached for better performance.
if (!rasterImage.IsCached)
{
rasterImage.CacheData();
}
// Define shift values for all four sides.
int leftShift = 10;
int rightShift = 10;
int topShift = 50;
int bottomShift = 50;
// Based on the shift values, apply the cropping on image. Crop method will shift the image bounds toward the center of image.
rasterImage.Crop(leftShift, rightShift, topShift, bottomShift);
// Save cropped image.
rasterImage.Save("cropped.png");
}
view raw crop-images.cs hosted with ❤ by GitHub

输入图像为Cropping:

crop image in C#

结果 折叠图像:

image cropping in C#

C# Image Cropping 使用一个直角

另一个有效的方法来挖掘图像是通过指定一个直角。

下面是一个代码样本,描述如何使用C#的直角进行图像挖掘:

// Load the image.
using (RasterImage rasterImage = (RasterImage)Image.Load("image.png"))
{
// Before cropping, the image should be cached for better performance.
if (!rasterImage.IsCached)
{
rasterImage.CacheData();
}
// Create an instance of Rectangle class with desired size and crop the image.
Rectangle rectangle = new Rectangle(20, 20, 20, 20);
rasterImage.Crop(rectangle);
// Save cropped image.
rasterImage.Save("cropped.png");
}

种植图像在 C# 与免费许可

你可以 获得免费的临时许可证 种植图像,没有评估限制。

创建您的 C# .NET Image Cropping 应用程序

在这篇文章中,您已经学会了如何在C#中有效地种植图像,我们展示了两种方法:使用转值和直角,现在您有能力构建您现有应用程序的图形挖掘应用或改进图表编辑能力。 人们在说什么,或感到自由与我们分享您的提问通过我们的 论坛.

此外,请考虑查看更先进的应用程序的 C# Crop PDF 功能。

此外,您还可以利用 Image Crop API 为增强图像处理能力,确保您的应用程序能够有效地处理各种图形收获任务。

对于那些深入探索图像处理的人来说, C# Crop Imagec# crop PDF 的功能为您的开发需求提供了广泛的工具。

此外,如果您正在寻找一个简单的解决方案,请考虑使用 C# Crop Image 技术,可以进一步简化图像编辑任务。

More in this category