ストローク効果とカラーフィル
この記事では、ストローク効果をカラーフィルでレンダリングする方法について説明します。 ストローク効果は、レイヤーとシェイプにストロークとボーダーを追加するために使用されます。 これを使用して、単色の線、カラフルなグラデーション、およびパターン化されたボーダーを作成できます。
ストローク効果をカラーフィルでレンダリングする手順は以下の通りです:
- 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 }); | |
} |