因此,Xamarin.ios的这个组件GPUImage最初位于目标c中,现在使用绑定在C#中工作。

我似乎无法获得其中一个类的工作子类GPUImageThreeInputFilter,该子类应该接受一个字符串,然后将其作为glsl处理。这是该类的样子:

using Foundation;
using System;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace GPUImage.Filters
{
    [Register ("GPUImageThreeInputFilter", true)]
    public class GPUImageThreeInputFilter : GPUImageTwoInputFilter
    {
        //
        // Static Fields
        //
        [CompilerGenerated]
        private static readonly IntPtr class_ptr;

        [CompilerGenerated]
        private static NSString _ThreeInputTextureVertexShaderString;

        //
        // Static Properties
        //
        [Field ("kGPUImageThreeInputTextureVertexShaderString", "__Internal")]
        public static NSString ThreeInputTextureVertexShaderString {
            get;
        }

        //
        // Properties
        //
        public override IntPtr ClassHandle {
            get;
        }

        //
        // Constructors
        //
        [Export ("init"), EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
        public GPUImageThreeInputFilter ();

        [EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
        protected GPUImageThreeInputFilter (NSObjectFlag t);

        [EditorBrowsable (EditorBrowsableState.Advanced), CompilerGenerated]
        protected internal GPUImageThreeInputFilter (IntPtr handle);

        //
        // Methods
        //
        [Export ("disableThirdFrameCheck"), CompilerGenerated]
        public virtual void DisableThirdFrameCheck ();
    }
}


我创建了这个的子类:

public class ImageProcess : GPUImageThreeInputFilter
    {
        public static new NSString ThreeInputTextureVertexShaderString =
               ((NSString)("    varying highp vec2 textureCoordinate;" +
                "    varying highp vec2 textureCoordinate2;" +
                "    varying highp vec2 textureCoordinate3;" +
                "" +
                "    uniform sampler2D inputImageTexture;" +
                "    uniform sampler2D inputImageTexture2;" +
                "    uniform sampler2D inputImageTexture3;" +
                "" +
                "    void main()" +
                "    {" +
                "          lowp vec4 one = texture2D(inputImageTexture, textureCoordinate);" +
                "          lowp vec4 two = texture2D(inputImageTexture2, textureCoordinate2);" +
                "          lowp vec4 three = texture2D(inputImageTexture3, textureCoordinate3);" +
                "          lowp vec4 out;" +
                "          float maxone = one.r + one.g + one.b;" +
                "          float maxtwo = two.r + two.g + two.b;" +
                "          float maxthree = three.r + three.g + three.b;" +
                "          if (maxone >= maxtwo && maxone >= maxthree)" +
                "          {" +
                "          out.r = one.r;" +
                "          out.b = one.b;" +
                "          out.g = one.g;" +
                "          };" +
                "          if (maxtwo >= maxone && maxtwo >= maxthree)" +
                "          {" +
                "          out.r = two.r;" +
                "          out.b = two.b;" +
                "          out.g = two.g;" +
                "          };" +
                "          if (maxthree >= maxtwo && maxthree >= maxone)" +
                "          {" +
                "          out.r = three.r;" +
                "          out.b = three.b;" +
                "          out.g = three.g;" +
                "          };" +
                "          out.a = 1.0;" +
                "          gl_FragColor = out;" +
                                      "     }"));
    }


子类的使用:

var firstFilter = new ImageProcess();

first.AddTarget(firstFilter);     // first, second, and third
first.ProcessImage();             // are unique GPUImagePicture
second.AddTarget(firstFilter);    // values (pictures) defined
second.ProcessImage();            // somewhere else.
third.AddTarget(firstFilter);
third.ProcessImage();
firstFilter.UseNextFrameForImageCapture();
firstFilter.AddTarget(output);    // outputs the end result to
                                  // the screen


子类应获取三个图像中最亮的像素,并从中返回一个图像。相反,它只是再次返回第一张图像,因为该字符串未在子类中注册。

因此,我要问的是,该类的适当子类应该是什么样的?接受的NSString应该放在哪里?我以前没有遇到过这样的课程。谢谢

更新:

我现在正在使用和重新使用here中找到的方法,但是对经过处理的颜色阵列进行的所有调用大约需要四到五分钟,而这最多需要几秒钟,因此我仍将尝试解决此问题。一点。

最佳答案

派生自定义类“ GPUImageThreeInputFilter”
来自基类GPUImageTwoInputFilter

那是你的意图吗?
也许您应该以不同的方式命名自定义类,并使其继承自GPUImageThreeInputFilter类。

关于c# - 这个基类的C#子类?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/45951321/

10-17 01:37