Пример #1
0
        void cropResize()
        {
            if (!imageCroppingBox1.Visible)
            {
                return;
            }

            int scr_width    = pictureBox1.Width;
            int scr_height   = pictureBox1.Height;
            var aspect_ratio = FFplay.ffplay_get_aspect_ratio();

            _width  = FFplay.ffplay_get_w();
            _height = FFplay.ffplay_get_h();
            int width = _width, height = _height;

            if (width < 1 || height < 1)
            {
                return;
            }

            height = scr_height;
            width  = (int)Math.Ceiling(height * aspect_ratio) & ~1;
            if (width > scr_width)
            {
                width  = scr_width;
                height = (int)Math.Ceiling(width / aspect_ratio) & ~1;
            }
            int x = (scr_width - width) / 2;
            int y = (scr_height - height) / 2;

            var oldScale = cropScale;

            cropScale = (double)_width / width;
            var newScale = oldScale / cropScale;


            imageCroppingBox1.Left = x;
            imageCroppingBox1.Top  = y;
            imageCroppingBox1.Size = new Size(width, height);

            if (imageCroppingBox1.IsDrawed)
            {
                imageCroppingBox1.SelectedRectangle = new Rectangle(
                    (int)(imageCroppingBox1.SelectedRectangle.X * newScale)
                    , (int)(imageCroppingBox1.SelectedRectangle.Y * newScale)
                    , (int)(imageCroppingBox1.SelectedRectangle.Width * newScale)
                    , (int)(imageCroppingBox1.SelectedRectangle.Height * newScale));
            }
            showCropInfo();
        }
Пример #2
0
        void cropStart()
        {
            cropAction = () =>
            {
                if (FFplay.ffplay_get_w() < 1 || FFplay.ffplay_get_h() < 1)
                {
                    return;
                }
                imageCroppingBox1.Clear();
                imageCroppingBox1.Show();
                cropResize();
                cropAction = null;
            };

            timer2.Start();
        }