Example #1
0
        public OverlayInfo Resize(SizeD oldOverSize, SizeD newOverSize, SizeD oldSrcSize, SizeD newSrcSize)
        {
            var rect       = GetRectangle(oldOverSize);
            var coefWidth  = newSrcSize.Width / oldSrcSize.Width;
            var coefHeight = newSrcSize.Height / oldSrcSize.Height;

            rect = new RectangleD(
                rect.X * coefWidth,
                rect.Y * coefHeight,
                rect.Width * coefWidth,
                rect.Height * coefHeight
                );
            var info = Clone();

            info.Warp         = Warp.Scale(coefWidth, coefHeight);
            coefWidth         = newOverSize.Width / rect.Width;
            coefHeight        = newOverSize.Height / rect.Height;
            info.SourceWidth  = (int)Math.Floor(newSrcSize.Width);
            info.SourceHeight = (int)Math.Floor(newSrcSize.Height);
            info.X            = (int)Math.Ceiling(rect.X);
            info.Y            = (int)Math.Ceiling(rect.Y);
            info.Width        = (int)Math.Floor(rect.Right) - info.X;
            info.Height       = (int)Math.Floor(rect.Bottom) - info.Y;
            info.SetCrop(RectangleD.FromLTRB(
                             (info.X - rect.X) * coefWidth,
                             (info.Y - rect.Y) * coefHeight,
                             (rect.Right - info.Width - info.X) * coefWidth,
                             (rect.Bottom - info.Height - info.Y) * coefHeight
                             ));
            return(info);
        }