none
How to use the GDI+ drawing in WPF?问题 RRS feed

  • 问题

  • // using System.Windows.Interop;
    
    using (var tempBitmap = new Gdi.Bitmap(width, height))
    {
        using (var g = Gdi.Graphics.FromImage(tempBitmap))
        {
            // Your GDI drawing here.
        }
    
        // Copy GDI bitmap to WPF bitmap.
        var hbmp = tempBitmap.GetHbitmap();
        var options = BitmapSizeOptions.FromEmptyOptions();
        this.WpfTarget.Source = Imaging.CreateBitmapSourceFromHBitmap(hbmp,
            IntPtr.Zero, Int32Rect.Empty, options);
    }
    
    // Redraw the WPF Image control.
    this.WpfTarget.InvalidateMeasure();
    this.WpfTarget.InvalidateVisual();
    编译时出现error CS0103: 当前上下文中不存在名称“Gdi”,环境是vs2012,是否缺少引用,引用是哪个?
    2013年10月16日 2:23

答案