有谁知道如何平滑下面这两个黄色图形的边缘?下面还有原图。
这是从磁盘加载 BMP 的代码。
static BitmapSource LoadBitmap(ImagingFactory _wicFactory, string path, ImageFormat imageFormat)
{
SharpDX.WIC.BitmapDecoder decoder = new SharpDX.WIC.BitmapDecoder(
_wicFactory,
path,
SharpDX.WIC.DecodeOptions.CacheOnDemand);
var formatConverter = new SharpDX.WIC.FormatConverter(_wicFactory);
formatConverter.Initialize(
decoder.GetFrame(0),
SharpDX.WIC.PixelFormat.Format32bppPBGRA,
SharpDX.WIC.BitmapDitherType.DualSpiral8x8,
null,
0.0,
SharpDX.WIC.BitmapPaletteType.Custom);
return formatConverter;
}
绘制图像的代码
var wicBitmap = new WicBitmap(_wicFactory, options.ImageSize.Width, options.ImageSize.Height, SharpDX.WIC.PixelFormat.Format32bppPBGRA,
BitmapCreateCacheOption.CacheOnLoad);
var renderTargetProperties = new RenderTargetProperties(RenderTargetType.Default, new D2DPixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied),
0, 0, RenderTargetUsage.None, FeatureLevel.Level_DEFAULT);
var renderTarget = new WicRenderTarget(_ddFactory, wicBitmap, renderTargetProperties);
renderTarget.AntialiasMode = AntialiasMode.Aliased;
var bitmapSource = LoadBitmap(_wicFactory, @"C:\fanv_elev.bmp", ImageFormat.Bmp);
var formatConverter = new FormatConverter(_wicFactory);
formatConverter.Initialize(bitmapSource, SharpDX.WIC.PixelFormat.Format32bppPBGRA, BitmapDitherType.Spiral8x8, null, 0f, BitmapPaletteType.MedianCut);
SharpDX.Direct2D1.Bitmap direct2DBitmap = SharpDX.Direct2D1.Bitmap.FromWicBitmap(bitmapRenderTarget, formatConverter);
...
renderTarget.DrawBitmap(direct2DBitmap, featureRect, 1.0f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);