2010-06-08 29 views
3

您是否知道任何使用WPF WriteableBitmap和理想的BackBuffer提供繪製簡單形狀(線條和可選其他形狀)方法的庫? 我知道有一個用於Silverlight的WriteableBitmapEx項目,但是WPF等價嗎?使用WPF的繪圖線WriteableBitmap.BackBuffer

+0

相關:[如何獲取WriteableBitmap DrawingContext](http://stackoverflow.com/questions/88488/getting-a-drawingcontext-for-a-wpf-writeablebitmap) – 2012-01-03 12:24:00

回答

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(); 
+4

你不需要明確處理()位圖。這是使用的目的。 – 2012-01-15 13:11:22

1

你似乎是使用位圖,但要求使用WriteableBitmap的解決方案。有一個WPF的WriteableBitmapEx。

+0

WriteableBitmapEx沒有最佳的性能,並且不能繪製文本;如果您需要的話,它只有線路更好的抗鋸齒系統。 – 2015-09-21 09:00:21