Class GaussianBlurSmartFilter

GaussianBlurSmartFilter class

Filter pintar GaussianBlur.

public sealed class GaussianBlurSmartFilter : SmartFilter

Konstruktor

NamaKeterangan
GaussianBlurSmartFilter()Menginisialisasi instance baru dariGaussianBlurSmartFilter kelas.

Properti

NamaKeterangan
BlendMode { get; set; }Mendapatkan atau menyetel mode pencampuran.
override FilterId { get; }Mendapat pengidentifikasi jenis filter pintar.
IsEnabled { get; set; }Mendapat atau menyetel status aktif filter pintar.
override Name { get; }Mendapatkan nama filter pintar.
Opacity { get; set; }Mendapat atau mengatur nilai opacity dari smart filter.
Radius { get; set; }Mendapat atau menyetel radius gaussian smart filter.
SourceDescriptor { get; }Struktur deskriptor sumber dengan data filter cerdas.

Metode

NamaKeterangan
Apply(RasterImage)Menerapkan filter saat ini ke inputRasterImage gambar.
ApplyToMask(Layer)Menerapkan filter saat ini ke inputLayer data topeng.
Clone()Membuat tiruan anggota dari instance tipe saat ini.

Bidang

NamaKeterangan
const FilterTypePengidentifikasi filter pintar saat ini.

Contoh

Contoh ini menunjukkan dukungan antarmuka filter cerdas.

[C#]

string sourceFilte = "r2_SmartFilters.psd";
string outputPsd = "out_r2_SmartFilters.psd";

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

using (var image = (PsdImage)Image.Load(sourceFilte))
{
    SmartObjectLayer smartObj = (SmartObjectLayer)image.Layers[1];

    // edit filter pintar
    GaussianBlurSmartFilter gaussianBlur = (GaussianBlurSmartFilter)smartObj.SmartFilters.Filters[0];

    // periksa nilai filter
    AssertAreEqual(3.1, gaussianBlur.Radius);
    AssertAreEqual(BlendMode.Dissolve, gaussianBlur.BlendMode);
    AssertAreEqual(90d, gaussianBlur.Opacity);
    AssertAreEqual(true, gaussianBlur.IsEnabled);

    // perbarui nilai filter
    gaussianBlur.Radius = 1;
    gaussianBlur.BlendMode = BlendMode.Divide;
    gaussianBlur.Opacity = 75;
    gaussianBlur.IsEnabled = false;
    AddNoiseSmartFilter addNoise = (AddNoiseSmartFilter)smartObj.SmartFilters.Filters[1];
    addNoise.Distribution = NoiseDistribution.Uniform;

    // tambahkan item filter baru
    var filters = new List<SmartFilter>(smartObj.SmartFilters.Filters);
    filters.Add(new GaussianBlurSmartFilter());
    filters.Add(new AddNoiseSmartFilter());
    smartObj.SmartFilters.Filters = filters.ToArray();

    // menerapkan perubahan
    smartObj.SmartFilters.UpdateResourceValues();

    // Terapkan filter
    smartObj.SmartFilters.Filters[0].Apply(image.Layers[2]);
    smartObj.SmartFilters.Filters[4].ApplyToMask(image.Layers[2]);

    image.Save(outputPsd);
}

using (var image = (PsdImage)Image.Load(outputPsd))
{
    SmartObjectLayer smartObj = (SmartObjectLayer)image.Layers[1];

    GaussianBlurSmartFilter gaussianBlur = (GaussianBlurSmartFilter)smartObj.SmartFilters.Filters[0];

    // periksa nilai filter
    AssertAreEqual(1d, gaussianBlur.Radius);
    AssertAreEqual(BlendMode.Divide, gaussianBlur.BlendMode);
    AssertAreEqual(75d, gaussianBlur.Opacity);
    AssertAreEqual(false, gaussianBlur.IsEnabled);

    AssertAreEqual(true, smartObj.SmartFilters.Filters[5] is GaussianBlurSmartFilter);
    AssertAreEqual(true, smartObj.SmartFilters.Filters[6] is AddNoiseSmartFilter);
}

Lihat juga