SharpDX Direct2D DrawBitmap流畅的图像

时间:2013-06-25 19:21:08

标签: c# direct2d sharpdx

有谁知道如何消除下面这两个黄色数字的边缘?下面是原始图像。

以下是从磁盘加载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);

enter image description here

enter image description here

0 个答案:

没有答案