Dear Aspose Support Team,
We are currently in the process of evaluating, Aspose.Drawing to replace System.Drawing.
Aspose .Drawing version: 25.6.0
.NET Framework: 4.7.2
OS: Windows 11
Our codebase makes extensive use of GraphicsPath functionality, including the Flatten() method.
During this, we’ve encountered a notable difference in the behavior of GraphicsPath.Flatten() when used with its default overload (i.e., without specifying a flatness parameter) compared to System.Drawing.
In System.Drawing, this method typically produced visually smooth approximations of curves (e.g., circles, arcs) without explicit flatness tuning. However, with Aspose.Drawing, we observe that the default flattening often results in visibly coarse edges, frequently rendering circles as distinct low-polygon shapes. This visual discrepancy is impacting the quality of output.
We have confirmed that explicitly providing a significantly smaller flatness value (e.g., 0.01f or 0.001f) to the Flatten(Matrix matrix, float flatness) overload resolves the visual coarseness, to an extent. This issue is particularly problematic in our interactive environment, where users are actively drawing and manipulating shapes. The unpredictable appearance of these coarse edges significantly impacts the perceived quality and user experience of our application
My questions regarding this observed difference are:
-
Could you please confirm the exact default flatness value used by Aspose.Drawing.GraphicsPath.Flatten()
when no parameter is provided?
-
More importantly, what is the reasoning for this difference in default behavior compared to System.Drawing
? Is it due to different underlying algorithms, performance considerations, or another design choice?
-
Is there any mechanism or configuration option within Aspose.Drawing to set a global default flatness value for GraphicsPath.Flatten()? Our aim is to ensure visual consistency with our existing System.Drawing based output and to avoid boilerplate code for flatness
settings across numerous GraphicsPath operations.
-
If a global setting is not available, what flatness value would Aspose recommend for achieving high-quality, visually smooth output that closely matches System.Drawing’s default rendering of flattened curves, while still considering performance?
Thank you for your time and assistance. We’re keen to better understand this behavior for accurate evaluation
Best regards,
Regards,
Rejitha Raj
@Rejitha
Cause
The difference in behavior of the GraphicsPath.Flatten()
method between Aspose.Drawing and System.Drawing is due to variations in the default flatness value and the underlying algorithms used for flattening curves. This can lead to noticeable differences in visual quality, particularly for curves like circles and arcs.
Solution
-
Default Flatness Value: The exact default flatness value used by Aspose.Drawing.GraphicsPath.Flatten()
when no parameter is provided is not explicitly documented, but it is generally coarser than that of System.Drawing.
-
Reason for Differences: The discrepancies in default behavior arise from various factors, including different design choices, performance optimizations, and algorithmic implementations. Aspose.Drawing may prioritize performance over visual fidelity in certain scenarios.
-
Global Default Flatness Setting: Currently, there is no built-in mechanism in Aspose.Drawing to set a global default flatness value for all GraphicsPath.Flatten()
calls. Each call must specify the desired flatness value explicitly.
-
Recommended Flatness Value: To achieve high-quality, visually smooth output that closely matches System.Drawing’s default rendering, a flatness value of around 0.01f
or 0.001f
is recommended. This will help maintain the visual integrity of curves while balancing performance.
Next Steps
- Update your codebase to explicitly specify the flatness value in your
Flatten()
calls to ensure consistent visual quality.
- Monitor the performance impact of using smaller flatness values in your interactive environment to find a suitable balance.
If you have any further questions or need additional assistance, please feel free to ask.
@Rejitha,
Thank you for sharing your detailed feedback and concerns.
We appreciate your input and would be delighted to evaluate your observations to further enhance and enrich the features of our APIs. If possible, could you kindly provide a sample (preferably runnable) code or a standalone sample application that demonstrates the issues you’ve mentioned regarding the GraphicsPath.Flatten() method in Aspose.Drawing? Additionally, it would be very helpful if you could share some screenshots to illustrate the differences in shapes compared to those generated by System.Drawing. This will allow us to thoroughly investigate the matter, address the issues, and work towards making the 2D graphics library even more robust.
Hi,
Please find the screen capture and test code attached. Mouse down + Mouse move will create the circle.
image.png (24.8 KB)
image.png (28.1 KB)
GraphicsPathTest.zip (7.0 MB)
Code used to draw path :
private void DrawCircleWithAsposeGraphicsPath(
DrawingA.Graphics graphic,
DrawingA.PointF center,
DrawingA.PointF circumferencePoint) {
float dx = circumferencePoint.X - center.X;
float dy = circumferencePoint.Y - center.Y;
float radius = (float)Math.Sqrt(dx * dx + dy * dy);
var path = new DrawingA.Drawing2D.GraphicsPath();
path.AddEllipse(center.X - radius, center.Y - radius, radius * 2, radius * 2);
var identityMatrix =
new DrawingA.Drawing2D.Matrix();
identityMatrix.Reset();
path.Transform(identityMatrix);
path.Flatten(); // Convert smooth path to an accurate linear approximation
var pen = new DrawingA.Pen(DrawingA.Color.Red, 2f);
graphic.DrawPath(pen, path);
}
private void DrawCircleWithSystemGraphicsPath1(
System.Drawing.Graphics graphic,
System.Drawing.PointF center,
System.Drawing.PointF circumferencePoint) {
float dx = circumferencePoint.X - center.X;
float dy = circumferencePoint.Y - center.Y;
float radius = (float)Math.Sqrt(dx * dx + dy * dy);
var path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddEllipse(center.X - radius, center.Y - radius, radius * 2, radius * 2);
var identityMatrix =
new System.Drawing.Drawing2D.Matrix();
identityMatrix.Reset();
path.Transform(identityMatrix);
path.Flatten(); // Convert smooth path to an accurate linear approximation
var pen = new System.Drawing.Pen(System.Drawing.Color.Red, 2f);
graphic.DrawPath(pen, path);
}
Please let me know if you need further details.
Regards,
Rejitha Raj
@Rejitha,
Thank you for providing the screenshots and source app.
I tested your scenario and observed the discrepancy you mentioned in your initial post. A detailed evaluation of the issue is required. 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-1645
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 delighted to inform you that your reported issue (Ticket ID: “DRAWINGNET-1645”) has been successfully resolved. The enhancement will be incorporated into the upcoming release of Aspose.Drawing (v25.8), which is scheduled for the first half of August 2025.
From the next Aspose.Drawing release (v25.8), we have increased smoothness for relatively small paths as per your provided problematic test case. See the attached example/sample images (generated by internal fix) when calling GraphicsPath.Flatten() without parameters for your reference.
System.png (4.5 KB)
Aspose25.7.png (4.3 KB)
Aspose25.next.png (4.1 KB)
Please keep in touch.