SoCoResource支持
Contents
[
Hide
]
SoCoResource支持
SoCoResource包含有关颜色填充图层的信息。本文演示了Aspose.PSD for .NET如何支持PSD文件中的SoCoResource。
- 使用Image类的工厂方法Load加载PSD文件作为图像。
- 从图像图层获取SoCoResource
- 设置所需属性
- 保存结果
以下代码片段显示了Aspose.PSD for .NET支持SoCoResource的方式。
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 | |
string sourceFileName = dataDir + "ColorFillLayer.psd"; | |
string exportPath = dataDir + "SoCoResource_Edited.psd"; | |
var im = (PsdImage)Image.Load(sourceFileName); | |
using (im) | |
{ | |
foreach (var layer in im.Layers) | |
{ | |
if (layer is FillLayer) | |
{ | |
var fillLayer = (FillLayer)layer; | |
foreach (var resource in fillLayer.Resources) | |
{ | |
if (resource is SoCoResource) | |
{ | |
var socoResource = (SoCoResource)resource; | |
if (socoResource.Color != Color.FromArgb(63, 83, 141)) | |
{ | |
throw new Exception("Color from SoCoResource was read wrong"); | |
} | |
socoResource.Color = Color.Red; | |
break; | |
} | |
} | |
break; | |
} | |
im.Save(exportPath); | |
} | |
} |