在C#中将PSD文件转换为PNG时裁剪PSD文件
Contents
[
Hide
]
使用Aspose.PSD for .NET,开发人员可以在将PSD图像转换为光栅格式时裁剪PSD图像。本主题解释了加载现有图像、裁剪它们并转换为光栅格式的方法。
在将PSD文件转换为PNG时裁剪PSD文件
下面提供的示例代码演示了在将PSD图像转换为PNG时如何裁剪PSD图像。
This file contains hidden or 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
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
string sourceFileName = dataDir + "1.psd"; | |
string exportPathPsd = dataDir + "CropTest.psd"; | |
string exportPathPng = dataDir + "CropTest.png"; | |
using (RasterImage image = Image.Load(sourceFileName) as RasterImage) | |
{ | |
image.Crop(new Rectangle(10, 30, 100, 100)); | |
image.Save(exportPathPsd, new PsdOptions()); | |
image.Save(exportPathPng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }); | |
} |