Пример #1
0
    protected override void ExecuteEffect(ref MagickImage input)
    {
        float       otherStrength = 1.0f - strenght;
        MagickImage otherImage    = new MagickImage(input);

        Texture2D otherTex = new Texture2D(base.tex.width, base.tex.height, base.tex.format, false);

        ImageProcessingHelper.WriteToTexture(otherImage, ref base.tex);

        input.AutoThreshold((AutoThresholdMethod)Mode);
        ImageProcessingHelper.WriteToTexture(input, ref otherTex);

        Texture2D newTex = new Texture2D(otherTex.width, otherTex.height, otherTex.format, false);

        for (int x = 0; x < newTex.width; x++)
        {
            for (int y = 0; y < newTex.height; y++)
            {
                Color a = otherTex.GetPixel(x, y) * strenght + otherStrength * base.tex.GetPixel(x, y);
                newTex.SetPixel(x, y, a);
            }
        }
        newTex.Apply();
        input = ImageProcessingHelper.GenerateMagicImage(newTex);
    }
Пример #2
0
    public void ApplyEffect(ref Texture2D otherTex)
    {
        tex = new Texture2D(otherTex.width, otherTex.height, otherTex.format, false);
        MagickImage tempImage = ImageProcessingHelper.GenerateMagicImage(otherTex);

        ExecuteEffect(ref tempImage);
        ImageProcessingHelper.WriteToTexture(tempImage, ref otherTex);
    }