public FrameContext(OverlayContext ctx, OverlayInfo info) { this.ctx = ctx; Info = info; Source = ctx.Source; Overlay = ctx.Overlay; SourceSize = ctx.SourceInfo.Size; OverlaySize = ctx.OverlayInfo.Size; Info = Info.Resize(SourceSize, OverlaySize); if (ctx.Render.Mode == FramingMode.Fit && SourceSize != ctx.TargetInfo.Size) { Info = Info.Resize(ctx.TargetInfo.Size, OverlaySize); Source = Source.Invoke(SourceSize.GetArea() < ctx.TargetInfo.Size.GetArea() ? ctx.Render.Upsize : ctx.Render.Downsize, ctx.TargetInfo.Width, ctx.TargetInfo.Height); SourceSize = ctx.TargetInfo.Size; } if (ctx.Render.Mode == FramingMode.Fit) { Info = Info.Shrink(SourceSize, OverlaySize); } var resizeFunc = Info.Width > OverlaySize.Width ? ctx.Render.Upsize : ctx.Render.Downsize; var crop = Info.GetCrop(); Overlay = ctx.Render.ResizeRotate(Overlay, resizeFunc, null, Info.Width, Info.Height, 0, crop, Info.Warp); OverlayMask = ctx.Render.ResizeRotate(ctx.OverlayMask, "BicubicResize", null, Info.Width, Info.Height, 0, crop, Info.Warp); InitColorAdjust(); }
public void TestShrink() { var info = new OverlayInfo { Width = 1940, Height = 808, X = -15 }; var shrinked = info.Shrink(new Size(1920, 1080), new Size(1280, 534)); var target = new OverlayInfo { Width = 1920, Height = 808, CropLeft = 98969, CropRight = 32990 }; Assert.AreEqual(target, shrinked); }