public OverlayInfo Invert(Size srcSize, Size overSize) { var rect = GetRectangle(overSize); var info = Clone(); var invertedRect = new RectangleD( -rect.X, -rect.Y, srcSize.Width, srcSize.Height ); info.Angle = -Angle; info.X = (int)Math.Ceiling(invertedRect.X); info.Y = (int)Math.Ceiling(invertedRect.Y); info.Width = (int)Math.Floor(invertedRect.Right) - info.X; info.Height = (int)Math.Floor(invertedRect.Bottom) - info.Y; info.SetCrop(RectangleD.FromLTRB( info.X - invertedRect.X, info.Y - invertedRect.Y, invertedRect.Right - info.Width - info.X, invertedRect.Bottom - info.Height - info.Y )); return(info.Resize(srcSize, invertedRect.Size, rect.Size, overSize)); }
public OverlayInfo Shrink(Size srcSize, Size overSize) { var info = Clone(); var excess = Rectangle.FromLTRB( Math.Max(0, -info.X), Math.Max(0, -info.Y), Math.Max(0, info.Width + info.X - srcSize.Width), Math.Max(0, info.Height + info.Y - srcSize.Height)); var widthCoef = (double)overSize.Width / info.Width; var heightCoef = (double)overSize.Height / info.Height; info.Width -= excess.Left + excess.Right; info.Height -= excess.Top + excess.Bottom; info.X = Math.Max(0, info.X); info.Y = Math.Max(0, info.Y); var crop = info.GetCrop(); info.SetCrop(RectangleD.FromLTRB( crop.Left + excess.Left * widthCoef, crop.Top + excess.Top * heightCoef, crop.Right + excess.Right * widthCoef, crop.Bottom + excess.Bottom * heightCoef)); return(info); }