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); }
public OverlayInfo Resize(SizeD newUnionSize) { var oldUnionSize = GetUnionSize(); var coefWidth = newUnionSize.Width / oldUnionSize.Width; var coefHeight = newUnionSize.Height / oldUnionSize.Height; return(Resize(new Size(BaseWidth, BaseHeight))); }
public RectangleD GetRectangle(SizeD overlaySize) { var crop = GetCrop(); var scaleWidth = Width / (overlaySize.Width - crop.Left - crop.Right); var scaleHeight = Height / (overlaySize.Height - crop.Top - crop.Bottom); return(new RectangleD( X - crop.Left * scaleWidth, Y - crop.Top * scaleHeight, Width + (crop.Right + crop.Left) * scaleWidth, Height + (crop.Bottom + crop.Top) * scaleHeight)); }
public RectangleD Scale(SizeD coefs) { return(Scale(coefs.Width, coefs.Height)); }