예제 #1
0
파일: TabButton.cs 프로젝트: CodeSuffer/TnT
        public TabButton()
        {
            InitializeComponent();

            this.Height = imageClicked.Height;
            this.Width = imageClicked.Width;

            button = new ImageButton(imageHover, imageClicked, imageUnclicked, "");
            button.Location = new Point(0, 0);
            this.Controls.Add(button);
            buttonX = new ImageButton(imageXHover, imageXClicked, imageXUnclicked, imageXUnclicked, "");
            buttonX.Location = new Point(this.Width - imageXClicked.Width - 5, 5);
            this.Controls.Add(buttonX);
            buttonX.BringToFront();

            button.MouseDown += Button_MouseDown;
            buttonX.Click += ButtonX_Click;
        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            RequestWindowFeature(WindowFeatures.NoTitle);
            bool cameraPreviewCallbackWithBuffer = false;

            SetContentView(Resource.Layout.CameraPreviewLayout);

            _bgrBuffers           = new ImageBufferFactory <Mat>(size => new Mat(size.Height, size.Width, DepthType.Cv8U, 3));
            _previewBitmapBuffers = new ImageBufferFactory <Android.Graphics.Bitmap>(s => Android.Graphics.Bitmap.CreateBitmap(s.Width, s.Height, Android.Graphics.Bitmap.Config.Rgb565));

            _topLayer = new ProcessedCameraPreview(this, cameraPreviewCallbackWithBuffer);
            _topLayer.PictureTaken += this.PictureTaken;
            _topLayer.ImagePreview += this.ImagePreview;

            _preview = new CameraPreview(this, _topLayer, cameraPreviewCallbackWithBuffer);

            RelativeLayout mainLayout = FindViewById <RelativeLayout>(Resource.Id.CameraPreiewRelativeLayout);

            mainLayout.AddView(_preview, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));
            mainLayout.AddView(_topLayer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent));

#if GL_VIEW
            _topLayer.SetZOrderOnTop(true);
#endif
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;

            ImageButton switchCameraButton = FindViewById <ImageButton>(Resource.Id.CameraPreviewSwitchCameraImageButton);
            if (Camera.NumberOfCameras <= 1)
            {
                switchCameraButton.Visibility = ViewStates.Invisible;
            }
            else
            {
                switchCameraButton.BringToFront();
            }
            switchCameraButton.Click += delegate
            {
                _preview.SwitchCamera();
            };

            ImageButton captureImageButton = FindViewById <ImageButton>(Resource.Id.CameraPreviewCaptureImageButton);
            captureImageButton.Click += delegate
            {
                Camera camera = _preview.Camera;

                if (camera != null)
                {
                    Camera.Parameters p = camera.GetParameters();
                    p.PictureFormat = Android.Graphics.ImageFormatType.Jpeg;
                    //p.PictureFormat = Android.Graphics.ImageFormatType.Rgb565;
                    camera.SetParameters(p);
                    camera.TakePicture(null, null, _topLayer);
                }
            };

            _lastCapturedImageButton        = FindViewById <ImageButton>(Resource.Id.capturedImageButton);
            _lastCapturedImageButton.Click += delegate
            {
                if (_lastSavedImageFile != null)
                {
                    Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.FromFile(new Java.IO.File(_lastSavedImageFile.FullName)));
                    intent.SetType("image/jpeg");
                    StartActivity(intent);
                }
            };
            _lastCapturedImageButton.BringToFront();

            _previewButtons           = new ImageButton[4];
            _previewFilters           = new ImageFilter[4];
            _previewButtons[0]        = FindViewById <ImageButton>(Resource.Id.previewImageButton);
            _previewFilters[0]        = null;
            _previewButtons[0].Click += delegate
            {
                if (_imageFilter != null)
                {
                    _imageFilter.Dispose();
                    _imageFilter = null;
                }
            };
            _previewButtons[1] = FindViewById <ImageButton>(Resource.Id.cannyImageButton);
            _previewFilters[1] = new CannyFilter(100, 60, 3);

            _previewButtons[2] = FindViewById <ImageButton>(Resource.Id.colorMapImageButton);
            _previewFilters[2] = new ColorMapFilter(Emgu.CV.CvEnum.ColorMapType.Autumn);

            //_previewFilters[3] = new ColorMapFilter(Emgu.CV.CvEnum.ColorMapType.Summer);
            //_previewFilters[3] = null;
            _previewButtons[3] = FindViewById <ImageButton>(Resource.Id.distorImageButton);
            _previewFilters[3] = new DistorFilter(0.5, 0.5, -1.5);

            for (int i = 1; i < _previewButtons.Length; ++i)
            {
                ImageFilter f = _previewFilters[i];
                _previewButtons[i].Click += delegate
                {
                    if (_imageFilter != null)
                    {
                        _imageFilter.Dispose();
                    }
                    _imageFilter = f.Clone() as ImageFilter;
                };
            }
        }
예제 #3
0
      protected override void OnCreate(Bundle bundle)
      {
         base.OnCreate(bundle);
         RequestWindowFeature(WindowFeatures.NoTitle);
         bool cameraPreviewCallbackWithBuffer = false;
         SetContentView(Resource.Layout.CameraPreviewLayout);

         _bgrBuffers = new ImageBufferFactory<Mat>(size => new Mat(size.Height, size.Width, DepthType.Cv8U, 3));
         _previewBitmapBuffers = new ImageBufferFactory<Android.Graphics.Bitmap>(s => Android.Graphics.Bitmap.CreateBitmap(s.Width, s.Height, Android.Graphics.Bitmap.Config.Rgb565));

         _topLayer = new ProcessedCameraPreview(this, cameraPreviewCallbackWithBuffer);
         _topLayer.PictureTaken += this.PictureTaken;
         _topLayer.ImagePreview += this.ImagePreview;
         
         _preview = new CameraPreview(this, _topLayer, cameraPreviewCallbackWithBuffer);

         RelativeLayout mainLayout = FindViewById<RelativeLayout>(Resource.Id.CameraPreiewRelativeLayout);
         
         mainLayout.AddView(_preview, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));
         mainLayout.AddView(_topLayer, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent));

#if GL_VIEW
         _topLayer.SetZOrderOnTop(true);
#endif
         RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;

         ImageButton switchCameraButton = FindViewById<ImageButton>(Resource.Id.CameraPreviewSwitchCameraImageButton);
         if (Camera.NumberOfCameras <= 1)
            switchCameraButton.Visibility = ViewStates.Invisible;
         else
         {
            switchCameraButton.BringToFront();
         }
         switchCameraButton.Click += delegate
         {
            _preview.SwitchCamera();
         };

         ImageButton captureImageButton = FindViewById<ImageButton>(Resource.Id.CameraPreviewCaptureImageButton);
         captureImageButton.Click += delegate
         {
            Camera camera = _preview.Camera;

            if (camera != null)
            {
               Camera.Parameters p = camera.GetParameters();
               p.PictureFormat = Android.Graphics.ImageFormatType.Jpeg;
               //p.PictureFormat = Android.Graphics.ImageFormatType.Rgb565;
               camera.SetParameters(p);
               camera.TakePicture(null, null, _topLayer);
            }
         };

         _lastCapturedImageButton = FindViewById<ImageButton>(Resource.Id.capturedImageButton);
         _lastCapturedImageButton.Click += delegate
         {
            if (_lastSavedImageFile != null)
            {
               Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.FromFile(new Java.IO.File(_lastSavedImageFile.FullName)));
               intent.SetType("image/jpeg");
               StartActivity(intent);
            }
         };
         _lastCapturedImageButton.BringToFront();

         _previewButtons = new ImageButton[4];
         _previewFilters = new ImageFilter[4];
         _previewButtons[0] = FindViewById<ImageButton>(Resource.Id.previewImageButton);
         _previewFilters[0] = null;
         _previewButtons[0].Click += delegate
         {
            if (_imageFilter != null)
            {
               _imageFilter.Dispose();
               _imageFilter = null;
            }
         };
         _previewButtons[1] = FindViewById<ImageButton>(Resource.Id.cannyImageButton);
         _previewFilters[1] = new CannyFilter(100, 60, 3);

         _previewButtons[2] = FindViewById<ImageButton>(Resource.Id.colorMapImageButton);
         _previewFilters[2] = new ColorMapFilter(Emgu.CV.CvEnum.ColorMapType.Autumn);
         
         //_previewFilters[3] = new ColorMapFilter(Emgu.CV.CvEnum.ColorMapType.Summer);
         //_previewFilters[3] = null;
         _previewButtons[3] = FindViewById<ImageButton>(Resource.Id.distorImageButton);
         _previewFilters[3] =  new DistorFilter(0.5, 0.5, -1.5);

         for (int i = 1; i < _previewButtons.Length; ++i)
         {
            ImageFilter f = _previewFilters[i];
            _previewButtons[i].Click += delegate
            {
               if (_imageFilter != null)
                  _imageFilter.Dispose();
               _imageFilter = f.Clone() as ImageFilter;
            };
         }
      }