Enum InterpolationMethod

InterpolationMethod enumeration

Packed fourCC values for Photoshop gradient interpolation method. Descriptor key: “gradientsInterpolationMethod”

public enum InterpolationMethod : uint

Values

NameValueDescription
Classic1197698163‘Gcls’ — Classic (legacy default when key is absent).
Perceptual1348825699‘Perc’ — Perceptual.
Linear1282306592‘Lnr ’ — Linear (note trailing space).
Smooth1399680879‘Smoo’ — Smooth.
Stripes1195986291‘GIMs’ — Stripes.

Examples

The following code demonstrates the support of gradient rendering with Smooth method.

[C#]

string sourceFile = "GradientOverlay.psd";
string outputFile = "output_GradientOverlay.psd";
string outputFilePng = "output_GradientOverlay.png";

var srcMethod = InterpolationMethod.Linear;
var newMethod = InterpolationMethod.Smooth;

var opt = new PsdLoadOptions()
{
    LoadEffectsResource = true,
};

using (var image = (PsdImage)Image.Load(sourceFile, opt))
{
    // Read
    var effect = image.Layers[1].BlendingOptions.Effects[0] as GradientOverlayEffect;
    var gradientSettings = effect.Settings;
    AssertAreEqual(srcMethod, gradientSettings.InterpolationMethod);

    // Change
    gradientSettings.InterpolationMethod = newMethod;

    image.Save(outputFile);
    image.Save(outputFilePng, new PngOptions() { ColorType = PngColorType.TruecolorWithAlpha });
}

// Check saved data
using (var image = (PsdImage)Image.Load(outputFile, opt))
{
    var effect = image.Layers[1].BlendingOptions.Effects[0] as GradientOverlayEffect;
    var gradientSettings = effect.Settings;

    AssertAreEqual(newMethod, gradientSettings.InterpolationMethod);
}

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

See Also