带颜色填充的描边效果
Contents
[
Hide
]
带颜色填充的描边效果
本文演示了如何渲染带颜色填充的描边效果。描边效果用于在图层和形状上添加描边和边框。它可以用于创建实色线条、丰富多彩的渐变,以及图案边框。
渲染带颜色填充的描边效果的步骤如下所示:
- 设置 LoadEffectsResource 属性。
- 使用 Image 类的 Load 工厂方法将 PSD 文件加载为图像,并定义 PsdLoadOptions。
- 设置 ColorFillSetting 的设置属性。
- 保存结果。
下面的代码片段展示了如何渲染带颜色填充的描边效果。
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
// For complete examples and data files, please go to https://github.com/aspose-psd/Aspose.PSD-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_PSD(); | |
// Implement rendering of Stroke effect with Color Fill for export | |
string sourceFileName = dataDir + "StrokeComplex.psd"; | |
string exportPath = dataDir + "StrokeComplexRendering.psd"; | |
string exportPathPng = dataDir + "StrokeComplexRendering.png"; | |
var loadOptions = new PsdLoadOptions() | |
{ | |
LoadEffectsResource = true | |
}; | |
using (var im = (PsdImage)Image.Load(sourceFileName, loadOptions)) | |
{ | |
for (int i = 0; i < im.Layers.Length; i++) | |
{ | |
var effect = (StrokeEffect)im.Layers[i].BlendingOptions.Effects[0]; | |
var settings = (ColorFillSettings)effect.FillSettings; | |
settings.Color = Color.DeepPink; | |
} | |
// Save psd | |
im.Save(exportPath, new PsdOptions()); | |
// Save png | |
im.Save(exportPathPng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha }); | |
} |