การใช้ Stroke Effect พร้อมกับการเติมสี

บทความนี้สาธิตวิธีการเรนเดอร์ Stroke effect พร้อมกับการเติมสี การใช้ Stroke effect เป็นวิธีในการเพิ่มเส้น Stroke และเส้นขอบสำหรับเลเยอร์และรูปร่าง สามารถใช้สร้างเส้นสีทึบ สีไล่ระดับ และเส้นขอบลายละเอียดได้

ขั้นตอนสำหรับการเรนเดอร์ Stroke effect พร้อมกับการเติมสีมีดังนี้:

โค้ดย่อยต่อไปนี้แสดงวิธีการเรนเดอร์ Stroke effect พร้อมกับการเติมสี

// 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 });
}