Exemplo n.º 1
0
        public HeirloomSurfaceView(Activity context, IntSize resolution, MultisampleQuality multisample = MultisampleQuality.None)
            : base(context)
        {
            //
            Holder.AddCallback(this);
            Holder.SetFixedSize(resolution.Width, resolution.Height);
            Holder.SetFormat(Format.Rgb888);

            Console.WriteLine($"[EGL] Creating OpenGL ES 3.0 Context");

            // Find best configuration for 24 bit color no depth
            var config = Egl.ChooseConfig(new EglConfigAttributes
            {
                RedBits     = 8,
                GreenBits   = 8,
                BlueBits    = 8,
                AlphaBits   = 0,
                DepthBits   = 0,
                StencilBits = 0,
                Samples     = 0
            });

            // Create OpenGL ES 3.0 Context & Surface
            EglContext = Egl.CreateContext(config);

            // Create render context, and set to initial size
            _renderContext = new AndroidRenderContext(this, multisample);
            _renderContext.SetDefaultSurfaceSize(resolution);
        }
Exemplo n.º 2
0
 public CameraView(Context context, Camera camera) : base(context)
 {
     this.camera = camera;
     Holder.AddCallback(this);
     // deprecated setting, but required on Android versions prior to 3.0
     Holder.SetType(SurfaceType.PushBuffers);
 }
Exemplo n.º 3
0
 private void InitView(Android.Hardware.Camera camera)
 {
     this.camera = camera;
     camera.SetDisplayOrientation(90);
     Holder.AddCallback(this);
     Holder.SetType(SurfaceType.PushBuffers);
 }
Exemplo n.º 4
0
        private void Initialize(IAttributeSet attrs = null)
        {
            Focusable = true;
            Holder.AddCallback(this);
            SetZOrderOnTop(true);
            Holder.SetFormat(Format.Transparent);

            if (attrs == null)
            {
                _gifMovie    = null;
                _movieWidth  = 0;
                _movieHeight = 0;
            }
            else
            {
                this.InitializeAttributes(attrs);
                string filePath;
                var    resourceId = attrs.GetAttributeResourceValue("http://schemas.android.com/apk/res/android", "src", 0);
                if (resourceId > 0)
                {
                    var inputStream = Context.Resources.OpenRawResource(resourceId);
                    SetAnimationStream(inputStream);
                }
                else if (!string.IsNullOrEmpty((filePath = attrs.GetAttributeValue(ElementExtensions.XmlNamespace, "file_path"))))
                {
                    FilePath = filePath;
                }
            }
        }
Exemplo n.º 5
0
 public SkiaView(Activity context) : base(context)
 {
     _context = context;
     SkiaPlatform.Initialize();
     Holder.AddCallback(this);
     _handler = new Handler(context.MainLooper);
 }
Exemplo n.º 6
0
        private void Init(Context context)
        {
            MjpegView.context = context;
            Holder.AddCallback(this);
            thread    = new MjpegViewThread(Holder, context);
            Focusable = true;
            if (!resume)
            {
                resume                 = true;
                overlayPaint           = new Paint();
                overlayPaint.TextAlign = Paint.Align.Left;
                overlayPaint.TextSize  = 12;
                overlayPaint.SetTypeface(Typeface.Default);
                overlayTextColor       = Color.White;
                overlayBackgroundColor = Color.Black;
                ovlPos      = MjpegView.POSITION_LOWER_RIGHT;
                displayMode = MjpegView.SIZE_STANDARD;
                dispWidth   = Width;
                dispHeight  = Height;

                Log.Debug("MjpegView", "init successfully!");
            }
            SetOverlayTextColor(Color.Green);
            DisplayMetrics dm = Resources.DisplayMetrics;

            mScreenWidth  = dm.WidthPixels;
            mScreenHeight = dm.HeightPixels;
            KeepScreenOn  = true;
        }
Exemplo n.º 7
0
 private void initView(Context context)
 {
     mMeasureHelper   = new MeasureHelper(this);
     mSurfaceCallback = new SurfaceCallback(this);
     Holder.AddCallback(mSurfaceCallback);
     //noinspection deprecation
     Holder.SetType(SurfaceType.Normal);
 }
 public CameraPreview(Context context, Camera camera, View cameraView) : base(context)
 {
     mCameraView = cameraView;
     mContext    = context;
     setCamera(camera);
     Holder.AddCallback(this);
     Holder.SetKeepScreenOn(true);
 }
 /// <summary>
 /// Initializes holder callback.
 /// </summary>
 private void Init()
 {
     if (!_addedHolderCallback)
     {
         Holder.AddCallback(this);
         _addedHolderCallback = true;
     }
 }
Exemplo n.º 10
0
        public CameraPreview(Context context, Android.Hardware.Camera camera) : base(context)
        {
            _camera = camera;
            _camera.SetDisplayOrientation(rotation);

            Holder.AddCallback(this);
            // deprecated but required on Android versions less than 3.0
            Holder.SetType(SurfaceType.PushBuffers);
        }
Exemplo n.º 11
0
        public CameraPreview(Context context, Android.Hardware.Camera camera) : base(context)
        {
            this.camera  = camera;
            this.context = context;

            //Surface holder callback is set so theat SurfaceChanged, Created, destroy...
            //Could be called from here.
            Holder.AddCallback(this);
        }
Exemplo n.º 12
0
 public CameraPreview(Context context, Camera camera, View cameraView, bool video = false) : base(context)
 {
     this.cameraView = cameraView;
     this.context    = context;
     SetCamera(camera);
     Holder.AddCallback(this);
     Holder.SetKeepScreenOn(true);
     isVideo = video;
 }
Exemplo n.º 13
0
        public CameraPreview(Context context, Android.Hardware.Camera camera) : base(context)
        {
            _mCamera = camera;
            Holder.AddCallback(this);

            _mSupportedPreviewSizes = _mCamera.GetParameters().SupportedPreviewSizes.ToList();
            _mSupportedPictureSizes = _mCamera.GetParameters().SupportedPictureSizes.ToList();
            Holder.SetType(SurfaceType.PushBuffers);
        }
Exemplo n.º 14
0
        public CameraPreview(Context context, Android.Hardware.Camera cameraa) : base(context)
        {
            camera = cameraa;
            camera.SetDisplayOrientation(90);// Вылетает на этой строчке !!! Если закоментировать - переходит к строке номер 68 и выдаёт такую же ошибку !!!

            //Surface holder callback is set so theat SurfaceChanged, Created, destroy...
            //Could be called from here.
            Holder.AddCallback(this);
            // deprecated but required on Android versions less than 3.0
            Holder.SetType(SurfaceType.PushBuffers);
        }
        public VeldridSurfaceView(Context context, GraphicsBackend backend, GraphicsDeviceOptions deviceOptions) : base(context)
        {
            if (!(backend == GraphicsBackend.Vulkan || backend == GraphicsBackend.OpenGLES))
            {
                throw new NotSupportedException($"{backend} is not supported on Android.");
            }

            _backend      = backend;
            DeviceOptions = deviceOptions;
            Holder.AddCallback(this);
        }
Exemplo n.º 16
0
    public CameraPreview(Context context, Android.Hardware.Camera camera) : base(context)
    {
        _camera = camera;
        _camera.SetDisplayOrientation(0);

        //Surface holder callback is set so theat SurfaceChanged, Created, destroy...
        //Could be called from here.
        Holder.AddCallback(this);
        // deprecated but required on Android versions less than 3.0
        Holder.SetType(SurfaceType.PushBuffers);
    }
Exemplo n.º 17
0
 public VulkanView(Context context, Instance instance = null) : base(context)
 {
     Holder.AddCallback(this);
     if (instance == null)
     {
         CreateDefaultInstance();
     }
     else
     {
         Instance = instance;
     }
     SetWillNotDraw(false);
 }
		void Init()
		{
			if (cameraAnalyzer == null)
				cameraAnalyzer = new CameraAnalyzer(this, this);

			cameraAnalyzer.ResumeAnalysis();

			if (!addedHolderCallback)
			{
				Holder.AddCallback(this);
				Holder.SetType(SurfaceType.PushBuffers);
				addedHolderCallback = true;
			}
		}
Exemplo n.º 19
0
        private void Initialize(Context context)
        {
            Args = new InputArgs();

            Holder.AddCallback(this);
            SetWillNotDraw(true);

            //this.Touch += (sender, e) => OnTouch(e.Event);
            _touch   = Observable.FromEventPattern <TouchEventArgs>(this, "Touch").Select(e => e.EventArgs.Event);
            _touches = _touch.Subscribe((e) => OnTouch(e));

            Model = new CanvasViewModel();
            Model.Initialize();
        }
Exemplo n.º 20
0
        private void Init()
        {
            if (_cameraAnalyzer == null)
            {
                _cameraAnalyzer = new CameraAnalyzer(this, this);
            }

            if (!addedHolderCallback)
            {
                Holder.AddCallback(this);
                Holder.SetType(SurfaceType.PushBuffers);
                addedHolderCallback = true;
            }
        }
Exemplo n.º 21
0
 public DanmakuSurfaceView(Context context, IAttributeSet attrs, int defStyle) : base(context, attrs, defStyle)
 {
     Speed = 16;
     Paint = new Paint
     {
         Color       = Color.WhiteSmoke,
         AntiAlias   = true,
         StrokeWidth = 2,
         TextSize    = 36
     };
     SetZOrderOnTop(true);
     Holder.AddCallback(this);
     Random = new Random(1);
     Holder.SetFormat(Format.Translucent);
     SetBackgroundColor(Color.Transparent);
     Paint.SetShadowLayer(2, 1, 1, Color.Black);
 }
Exemplo n.º 22
0
        private void Init()
        {
            if (_cameraAnalyzer == null)
            {
                _cameraAnalyzer = new CameraAnalyzer(this, this);
            }

            _cameraAnalyzer.ResumeAnalysis();

            if (!addedHolderCallback)
            {
                Holder.AddCallback(this);

                if (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.Honeycomb)
                {
#pragma warning disable CS0618 // Type or member is obsolete
                    Holder.SetType(SurfaceType.PushBuffers);
#pragma warning restore CS0618 // Type or member is obsolete
                }

                addedHolderCallback = true;
            }
        }
Exemplo n.º 23
0
        ///////////////////////////////////////////////

        public VulkanView(Context context)
            : base(context)
        {
            SetWillNotDraw(false);
            Holder.AddCallback(this);
        }
Exemplo n.º 24
0
        public void Initialize(Context context)
        {
            Holder.AddCallback(this);
            SetWillNotDraw(true);

            _touch   = Observable.FromEventPattern <TouchEventArgs>(this, "Touch").Select(e => e.EventArgs.Event);
            _touches = _touch.Subscribe((e) => OnTouch(e));

            Renderer = new SurfaceRenderer();
            View     = new DrawingView(
                new Assembly[]
            {
                typeof(Bootstrapper).GetTypeInfo().Assembly,
                typeof(CanvasView).GetTypeInfo().Assembly
            });

            var canvas = View.Layers.LastOrDefault();

            canvas.Downs = Observable.FromEventPattern <Android.Views.View.TouchEventArgs>(this, "Touch")
                           .Where(e => (e.EventArgs.Event.Action & MotionEventActions.Mask) == MotionEventActions.Down && e.EventArgs.Event.PointerCount == 1)
                           .Select(e =>
            {
                float px = e.EventArgs.Event.GetX();
                float py = e.EventArgs.Event.GetY();

                double x = canvas.EnableSnap ?
                           canvas.Snap(px - Renderer.PanX, canvas.SnapX * Renderer.Zoom) : px - Renderer.PanX;

                double y = canvas.EnableSnap ?
                           canvas.Snap(py - Renderer.PanY, canvas.SnapY * Renderer.Zoom) : py - Renderer.PanY;

                x /= Renderer.Zoom;
                y /= Renderer.Zoom;

                return(new Vector2(x, y));
            });

            canvas.Ups = Observable.FromEventPattern <Android.Views.View.TouchEventArgs>(this, "Touch")
                         .Where(e => (e.EventArgs.Event.Action & MotionEventActions.Mask) == MotionEventActions.Up && e.EventArgs.Event.PointerCount == 1)
                         .Select(e =>
            {
                float px = e.EventArgs.Event.GetX();
                float py = e.EventArgs.Event.GetY();

                double x = canvas.EnableSnap ?
                           canvas.Snap(px - Renderer.PanX, canvas.SnapX * Renderer.Zoom) : px - Renderer.PanX;

                double y = canvas.EnableSnap ?
                           canvas.Snap(py - Renderer.PanY, canvas.SnapY * Renderer.Zoom) : py - Renderer.PanY;

                x /= Renderer.Zoom;
                y /= Renderer.Zoom;

                return(new Vector2(x, y));
            });

            canvas.Moves = Observable.FromEventPattern <Android.Views.View.TouchEventArgs>(this, "Touch")
                           .Where(e => (e.EventArgs.Event.Action & MotionEventActions.Mask) == MotionEventActions.Move && e.EventArgs.Event.PointerCount == 1)
                           .Select(e =>
            {
                float px = e.EventArgs.Event.GetX();
                float py = e.EventArgs.Event.GetY();

                double x = canvas.EnableSnap ?
                           canvas.Snap(px - Renderer.PanX, canvas.SnapX * Renderer.Zoom) : px - Renderer.PanX;

                double y = canvas.EnableSnap ?
                           canvas.Snap(py - Renderer.PanY, canvas.SnapY * Renderer.Zoom) : py - Renderer.PanY;

                x /= Renderer.Zoom;
                y /= Renderer.Zoom;

                return(new Vector2(x, y));
            });

            canvas.Native = this;

            View.Initialize();

            // background layer
            View.Layers[0].Background.A = 0xFF;
            View.Layers[0].Background.R = 0xFF;
            View.Layers[0].Background.G = 0xFF;
            View.Layers[0].Background.B = 0xFF;

            // drawing layer
            View.Layers[1].Background.A = 0xFF;
            View.Layers[1].Background.R = 0xF5;
            View.Layers[1].Background.G = 0xF5;
            View.Layers[1].Background.B = 0xF5;

            View.CreateGrid(600.0, 600.0, 30.0, 0.0, 0.0);
        }
Exemplo n.º 25
0
 public CameraSurface(global::Android.Content.Context context)
     : base(context)
 {
     Holder.AddCallback(this);
 }
Exemplo n.º 26
0
 public InvalidationAwareSurfaceView(Context context) : base(context)
 {
     Holder.AddCallback(this);
     _handler = new Handler(context.MainLooper);
 }
Exemplo n.º 27
0
 private void Initialize()
 {
     Holder.AddCallback(this);
 }
 public PlaySurfaceView(Context context) : base(context)
 {
     M_hHolder = this.Holder;
     Holder.AddCallback(this);
 }
Exemplo n.º 29
0
 private void Initialize()
 {
     surfaceFactory = new SurfaceFactory();
     Holder.AddCallback(this);
 }
 private void Init()
 {
     _cameraAnalyzer = new CameraAnalyzer(this, ScanningOptions);
     Holder.AddCallback(this);
     Holder.SetType(SurfaceType.PushBuffers);
 }