IRONSOFTWAREHOME
Point Casting
using IronSoftware.Drawing;

Point point = new Point(23, 50);

// Implicit casting from IronSoftware.Drawing.Point to System.Drawing.Point
System.Drawing.Point systemPoint = point;

// Implicit casting from IronSoftware.Drawing.Point to SixLabors.ImageSharp.Point
SixLabors.ImageSharp.Point sixPoint = point;

SixLabors.ImageSharp.PointF pointFloatS = new SixLabors.ImageSharp.PointF(22.5f, 35.5f);

// Implicit casting from SixLabors.ImageSharp.PointF to IronSoftware.Drawing.PointF
PointF pointFloatI = pointFloatS;
NuGet Download
PM > Install-Package IronSoftware.System.Drawing
Point Casting

Point Casting

Point and PointF classes were originally created in IronSoftware.Drawing to match the functionalities available in other drawing libraries, such as System.Drawing, SixLabors.ImageSharp, Maui.Graphics, and SkiaSharp. As a result, IronSoftware.Drawing enables implicit casting for Point and PointF objects, allowing them to be used across libraries and manipulated by users in the program.

The code snippet above demonstrates how implicit casting is achieved. An IronSoftware.Drawing.Point object is cast to a Point object from another library, while the second snippet shows the opposite conversion. To perform implicit casting, simply assign the IronSoftware.Drawing.Point object to the variable of the desired library.

It's important to note that implicit casting does not apply to all libraries. For instance, casting System.Drawing.PointF to IronSoftware.Drawing.PointF is not possible, as it is not supported by System.Drawing. However, casting IronSoftware.Drawing.Point and PointF to other libraries is possible. When casting from an IronSoftware.Drawing.Point object, the value type of the coordinates changes from System.Double to System.Int32, whereas for PointF, the System.Single value is maintained after casting.

View on GitHub

Ready to Get Started?

Nuget Downloads 19,661,086Version:2025.3just released

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required