3

您是否知道任何提供使用 WPF WriteableBitmap 和理想的 BackBuffer 绘制简单形状(线条和可选的其他形状)的方法的库?我知道 Silverlight 有一个 WriteableBitmapEx 项目,但是有 WPF 等价物吗?

4

2 回答 2

7

我想这是我问题的答案:)

_plotBitmap.Lock();

var b = new Bitmap(_plotBitmap.PixelWidth,
                   _plotBitmap.PixelHeight,
                   _plotBitmap.BackBufferStride,
                   System.Drawing.Imaging.PixelFormat.Format24bppRgb, 
                   _plotBitmap.BackBuffer);

using(var bitmapGraphics = System.Drawing.Graphics.FromImage(b))
{
    bitmapGraphics.SmoothingMode = SmoothingMode.HighSpeed;
    bitmapGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
    bitmapGraphics.CompositingMode = CompositingMode.SourceCopy;
    bitmapGraphics.CompositingQuality = CompositingQuality.HighSpeed;
    bitmapGraphics.DrawLine(Pens.Gold,2,2,222,222);
}

_plotBitmap.AddDirtyRect(new Int32Rect(0,0,_plotBitmap.PixelWidth,_plotBitmap.PixelHeight));
_plotBitmap.Unlock();
于 2010-06-08T19:46:46.217 回答
2

您似乎正在使用 Bitmap,但要求使用 WriteableBitmap 的解决方案。WPF 有一个 WriteableBitmapEx。

于 2013-07-31T17:09:50.947 回答