jingwood / d2dlib

A .NET library for hardware-accelerated, high performance, immediate mode rendering via Direct2D.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DrawPath and FillPath throw exception

MarkhusGenferei opened this issue · comments

Hi, This library is really great !

I am exploring geometries. In a form subclassing D2DForm, the code sample below throws a System.AccessViolationException : 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'

What am I doing wrong ?
Thank you

protected override void OnRender(D2DGraphics g)
{
  g.Clear(D2DColor.FromGDIColor(this.BackColor));
  
  using (var rect = this.Device.CreateRectangleGeometry(new D2DRect(10, 10, 20, 20)))
  {
     g.DrawPath(rect, D2DColor.BlueViolet, 1, D2DDashStyle.Dash);
  }
  
  using (var circle = this.Device.CreateEllipseGeometry(new D2DPoint(100, 100), new D2DSize(50, 50)))
  {
     using (var pen = this.Device.CreatePen(D2DColor.BlueViolet, D2DDashStyle.Dash))
     {
	  if (pen != null)
	  {
		  g.DrawPath(circle, pen, 2);
		  g.FillPath(circle, D2DColor.DarkBlue);
	  }
     }
  }
}

Confirmed that is a bug from CreateRectangleGeometry, please wait for it get fix. Thanks for report!

Thank you ! It looks this also apply to ellipse geometries.