PsdImage.AddRegularLayer
PsdImage.AddRegularLayer method
添加一个新的常规层。
public Layer AddRegularLayer()
返回值
创建了常规层。
例子
下面的代码展示了如何将新生成的常规层添加到 PsdImage 中。
[C#]
string sourceFileName = "OneLayer.psd";
string exportPath = "OneLayerEdited.psd";
string exportPathPng = "OneLayerEdited.png";
using (var im = (PsdImage)Image.Load(sourceFileName))
{
//准备两个int数组
var data1 = new int[2500];
var data2 = new int[2500];
var rect1 = new Rectangle(0, 0, 50, 50);
var rect2 = new Rectangle(0, 0, 100, 25);
for (int i = 0; i < 2500; i++)
{
data1[i] = -10000000;
data2[i] = -10000000;
}
var layer1 = im.AddRegularLayer();
layer1.Left = 25;
layer1.Top = 25;
layer1.Right = 75;
layer1.Bottom = 75;
layer1.SaveArgb32Pixels(rect1, data1);
var layer2 = im.AddRegularLayer();
layer2.Left = 25;
layer2.Top = 150;
layer2.Right = 125;
layer2.Bottom = 175;
layer2.SaveArgb32Pixels(rect2, data2);
// 保存psd
im.Save(exportPath, new PsdOptions());
// 保存png
im.Save(exportPathPng, new PngOptions());
}
也可以看看
- class Layer
- class PsdImage
- 命名空间 Aspose.PSD.FileFormats.Psd
- 部件 Aspose.PSD