views:

231

answers:

1

Do you know any library that provides methods to draw simple shapes (lines and optionally other shapes) using WPF WriteableBitmap and ideally BackBuffer? I know that there is a WriteableBitmapEx project for silverlight but is there WPF equivalent?

+1  A: 

I guess here is answer to my question :)

        _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);
            bitmapGraphics.Dispose();
        }
        _plotBitmap.AddDirtyRect(new Int32Rect(0,0,_plotBitmap.PixelWidth,_plotBitmap.PixelHeight));
        _plotBitmap.Unlock();
adrin