Example #1
0
        private void AddHighlightView()
        {
            Crop = new HighlightView(_imageView);

            var width  = _bitmap.Width;
            var height = _bitmap.Height;

            var imageRect = new Rect(0, 0, width, height);

            var cropWidth  = Math.Min(width, height) * 4 / 5;
            var cropHeight = cropWidth;

            if (_aspectX != 0 && _aspectY != 0)
            {
                if (_aspectX > _aspectY)
                {
                    cropHeight = cropWidth * _aspectY / _aspectX;
                }
                else
                {
                    cropWidth = cropHeight * _aspectX / _aspectY;
                }
            }

            var x = (width - cropWidth) / 2;
            var y = (height - cropHeight) / 2;

            var cropRect = new RectF(x, y, x + cropWidth, y + cropHeight);

            Crop.Setup(_imageView.ImageMatrix, imageRect, cropRect, _aspectX != 0 && _aspectY != 0);

            _imageView.ClearHighlightViews();
            Crop.Focused = true;
            _imageView.AddHighlightView(Crop);
        }