PsdImage.AddPosterizeAdjustmentLayer

PsdImage.AddPosterizeAdjustmentLayer method

Adds Posterize Adjustment layer.

public PosterizeLayer AddPosterizeAdjustmentLayer()

Return Value

PosterizeLayer instance.

Examples

The following code demonstrates the ability to add PosterizeAdjustmentLayer through PsdImage.

[C#]

string srcFile = "zendeya.psd";
string outFile = "zendeya.psd.out.psd";

using (PsdImage psdImage = (PsdImage)Image.Load(srcFile))
{
    psdImage.AddPosterizeAdjustmentLayer();
    psdImage.Save(outFile);
}

// Check saved changes
using (PsdImage image = (PsdImage)Image.Load(
           outFile,
           new PsdLoadOptions { LoadEffectsResource = true }))
{
    AssertAreEqual(2, image.Layers.Length);

    PosterizeLayer posterizeLayer = (PosterizeLayer)image.Layers[1];

    AssertAreEqual(true, posterizeLayer is PosterizeLayer);
}

void AssertAreEqual(object expected, object actual, string message = null)
{
    if (!object.Equals(expected, actual))
    {
        throw new Exception(message ?? "Objects are not equal.");
    }
}

See Also