您是否知道使用WPF WriteableBitmap和理想的BackBuffer提供绘制简单形状(线条和其他可选形状)的方法的库? 我知道有一个适用于Silverlight的WriteableBitmapEx项目,但WPF是否等效?
答案 0 :(得分: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();
答案 1 :(得分:1)
您似乎正在使用Bitmap,但要求使用WriteableBitmap的解决方案。 WPF有一个WriteableBitmapEx。