枚举 ResizeType

ResizeType enumeration

指定调整大小的类型。

public enum ResizeType

名称描述
None0在调整大小操作期间,像素不会被保留。
LeftTopToLeftTop1新图像的左上点将与原始图像的左上点重合。如有需要,将进行裁剪。
RightTopToRightTop2新图像的右上点将与原始图像的右上点重合。如有需要,将进行裁剪。
RightBottomToRightBottom3新图像的右下点将与原始图像的右下点重合。如有需要,将进行裁剪。
LeftBottomToLeftBottom4新图像的左下点将与原始图像的左下点重合。如有需要,将进行裁剪。
CenterToCenter5新图像的中心将与原始图像的中心重合。如有需要,将进行裁剪。
LanczosResample6使用 a=3 的 Lanczos 算法进行重采样。
NearestNeighbourResample7使用最近邻算法进行重采样。
AdaptiveResample8使用基于加权和混合有理函数以及 lanczos3 插值算法的自适应算法进行重采样。
BilinearResample9使用双线性插值进行重采样。需要时,可进行图像预过滤以在重采样前去除噪声。
HighQualityResample10高质量的重采样
CatmullRom11Catmull-Rom 三次插值方法。
CubicConvolution12立方卷积插值方法
CubicBSpline13CubicBSpline 三次插值方法
Mitchell14Mitchell 三次插值方法
SinC15Sinc(Lanczos3)三次插值方法
Bell16Bell 插值方法

示例

使用特定的缩放类型调整图像大小。

[C#]

using (var image = Image.Load("Photo.jpg"))
{
    image.Resize(640, 480, ResizeType.CatmullRom);
    image.Save("ResizedPhoto.jpg");

    image.Resize(1024, 768, ResizeType.CubicConvolution);
    image.Save("ResizedPhoto2.jpg");

    var resizeSettings = new ImageResizeSettings
    {
        Mode = ResizeType.CubicBSpline,
        FilterType = ImageFilterType.SmallRectangular
    };

    image.Resize(800, 800, resizeSettings);
    image.Save("ResizedPhoto3.jpg");
}

此示例加载图像并使用多种调整大小方法对其进行缩放。

[C#]

string dir = "c:\\temp\\";

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    // 使用最近邻重采样将尺寸放大 2 倍。
    image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
    image.Save(dir + "upsample.nearestneighbour.gif");
}

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    // 使用最近邻重采样将尺寸缩小 2 倍。
    image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.NearestNeighbourResample);
    image.Save(dir + "downsample.nearestneighbour.gif");
}

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    // 使用双线性重采样将尺寸放大 2 倍。
    image.Resize(image.Width* 2, image.Height* 2, Aspose.Imaging.ResizeType.BilinearResample);
    image.Save(dir + "upsample.bilinear.gif");
}

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(dir + "sample.gif"))
{
    // 使用双线性重采样将尺寸缩小 2 倍。
    image.Resize(image.Width / 2, image.Height / 2, Aspose.Imaging.ResizeType.BilinearResample);
    image.Save(dir + "downsample.bilinear.gif");
}

另请参见