public static void AddUnsharpMask(WicProcessingContext ctx) { var ss = ctx.Settings.UnsharpMask; if (!ctx.Settings.Sharpen || ss.Radius <= 0d || ss.Amount <= 0) { return; } var fmt = ctx.Source.Format; if (fmt.NumericRepresentation == PixelNumericRepresentation.Float) { var mapx = ctx.AddDispose(KernelMap <float> .MakeBlurMap(ctx.Source.Width, ss.Radius, 1, false, true)); var mapy = ctx.AddDispose(KernelMap <float> .MakeBlurMap(ctx.Source.Height, ss.Radius, 1, false, true)); ctx.Source = ctx.AddDispose(new UnsharpMaskTransform <float, float>(ctx.Source, mapx, mapy, ss)); } else { var mapx = ctx.AddDispose(KernelMap <int> .MakeBlurMap(ctx.Source.Width, ss.Radius, 1, false, false)); var mapy = ctx.AddDispose(KernelMap <int> .MakeBlurMap(ctx.Source.Height, ss.Radius, 1, false, false)); if (fmt.NumericRepresentation == PixelNumericRepresentation.Fixed) { ctx.Source = ctx.AddDispose(new UnsharpMaskTransform <ushort, int>(ctx.Source, mapx, mapy, ss)); } else { ctx.Source = ctx.AddDispose(new UnsharpMaskTransform <byte, int>(ctx.Source, mapx, mapy, ss)); } } }
public WicUnsharpMask(WicTransform prev) : base(prev) { var ss = Context.Settings.UnsharpMask; if (ss.Radius <= 0 || ss.Amount <= 0) { return; } var mapx = KernelMap.MakeBlurMap(Context.Width, ss.Radius); var mapy = KernelMap.MakeBlurMap(Context.Height, ss.Radius); Source = new WicUnsharpMask8bpc(Source, mapx, mapy, ss); }
public WicUnsharpMask(WicTransform prev) : base(prev) { var ss = Context.Settings.UnsharpMask; if (ss.Radius <= 0d || ss.Amount <= 0) { return; } var fmt = PixelFormat.Cache[Source.GetPixelFormat()]; mapx = KernelMap <int> .MakeBlurMap(Context.Width, ss.Radius, 1u, fmt.AlphaRepresentation != PixelAlphaRepresentation.None); mapy = KernelMap <int> .MakeBlurMap(Context.Height, ss.Radius, 1u, fmt.AlphaRepresentation != PixelAlphaRepresentation.None); Source = source = new WicUnsharpMask <byte, int>(Source, mapx, mapy, ss); }