NotImplementedException in Aspose.Drawing.GraphicsPath.IsOutlineVisible

Hi Support Team,

We are experiencing a NotImplementedException when attempting to use the GraphicsPath.IsOutlineVisible method from the Aspose.Drawing library in our application.

Problem Description:
When calling GraphicsPath.IsOutlineVisible(PointF point, Pen pen), an exception of type System.NotImplementedException is thrown. This occurs consistently whenever this method is invoked.

Steps to Reproduce

PointF[] floatPoints =
    new PointF[] { new PointF(1.0f, 1.0f), new PointF(5.5f, 4.5f) };
    GraphicsPath pt = new GraphicsPath();
pt.AddLines(floatPoints);
asposeGraphics.DrawPath(new Pen(Color.Pink, 2), pt);
using (var hitPen = new Pen(Color.Red, 2f)) {
    pt.IsOutlineVisible(floatPoints[0], hitPen);
}

Environment Details:

  • Aspose.Drawing Product and Version: Aspose.Drawing for .NET, Version 25.6.0

  • .NET Target Framework: .NET Framework 4.7.2

  • Operating System : Windows 11

  • Application Type: WPF Application

- Full Stack Trace of the Exception:
- System.NotImplementedException
  HResult=0x80004001
  Message=GraphicsPath.IsOutlineVisible(PointF point, Pen pen)
  Source=Aspose.Drawing
  StackTrace:
   at System.Drawing.Drawing2D.GraphicsPath.IsOutlineVisible(PointF point, Pen pen)
   at AsposeTestApp.MainWindow.DrawImage_MouseMove(Object sender, MouseEventArgs e) in MainWindow.xaml.cs:line 137
   at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()

Questions:

  1. Is GraphicsPath.IsOutlineVisible currently supported by Aspose.Drawing on the specified platform/environment? If not, is there a timeline for its implementation?
  2. Are there any recommended workarounds or alternative methods within Aspose.Drawing that can achieve similar hit-testing functionality for a GraphicsPath with a Pen?
  3. If this method is indeed not implemented, what is the suggested approach for handling this scenario when migrating from System.Drawing.Common?

Thank you for your time and assistance. We look forward to your prompt response.
Note : We are using an evaluation license.

Regards,
Rejitha Raj

@Rejitha

Cause

The NotImplementedException you are encountering when using the GraphicsPath.IsOutlineVisible method indicates that this specific functionality is not currently supported in the Aspose.Drawing library. This is a known limitation, and the method is not implemented in the version you are using.

Solution

  1. Alternative Methods: Since IsOutlineVisible is not available, you can consider using other methods for hit-testing. For example, you can manually check if a point is within the bounds of the GraphicsPath using the GetBounds() method and then perform additional checks based on the pen’s properties.

  2. Custom Hit Testing: You can create a custom hit-testing function that checks if a point is near the outline of the path based on the pen’s width. This may involve calculating the distance from the point to the path’s segments.

Code Example

Here’s a simple example of how you might implement a custom hit-testing method:

public bool IsPointNearPath(PointF point, GraphicsPath path, Pen pen)
{
    // Get the bounds of the path
    RectangleF bounds = path.GetBounds();
    
    // Check if the point is within the bounds
    if (bounds.Contains(point))
    {
        // Additional logic to check proximity to the path outline
        // This is a simplified example; you may need to implement more complex logic
        float penWidth = pen.Width / 2;
        return true; // Replace with actual distance check logic
    }
    return false;
}

Next Steps

  • Implement the custom hit-testing logic in your application.
  • Keep an eye on updates from Aspose, as they may add support for this method in future releases. You can check their release notes or contact support for timelines on feature implementations.

If you have any further questions or need additional assistance, please feel free to ask!

@Rejitha,

Thanks for pointing it out.

I tested your scenario/case in a WPF app and noticed the issue as you mentioned. I found an exception: “System.NotImplementedException: ‘GraphicsPath.IsOutlineVisible(PointF point, Pen pen)’” as you described. It seems the method is not implemented yet. We will look into it to implement it (if feasible). We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): DRAWINGNET-1643

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@Rejitha,

We are pleased to inform you that your issue (Ticket ID: “DRAWINGNET-1643”) has been resolved. The enhancement/fix will be included in an upcoming release(Aspose.Drawing for .NET v25.7) that we plan to release within a week or so. You will be notified when the next version is released.

Stay tuned!

Thanks for the quick response.
Regards,
Rejitha Raj

@Rejitha,

You are welcome. We will keep you posted with updates on the release (once available).