PsdImageAddLayer Method
Adds the layer.

Namespace: Aspose.PSD.FileFormats.Psd
Assembly: Aspose.PSD (in Aspose.PSD.dll) Version: 20.7
Syntax
public void AddLayer(
	Layer layer
)

Parameters

layer
Type: Aspose.PSD.FileFormats.Psd.LayersLayer
The layer.
Examples
The following example demonstrates how you can draw on a newly created layer if the simple constructor version is used in Aspose.PSD
[C#]

string outputFilePath = "output.psd";

int width = 100;
int height = 100;
using (var image = new PsdImage(width, height))
{
    var layer = new Layer();
    layer.Bottom = height;
    layer.Right = width;
    image.AddLayer(layer);

    Graphics graphic = new Graphics(layer);
    graphic.Clear(Color.Yellow);

    // draw a rectangle with Pen tool
    graphic.DrawRectangle(new Pen(Color.Red), new Rectangle(30, 10, 40, 80));

    // draw another rectangle with Solid Brush in Blue color
    graphic.DrawRectangle(new Pen(new SolidBrush(Color.Blue)), new Rectangle(10, 30, 80, 40));

    image.Save(outputFilePath);
}
See Also