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. In the first snippet, 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 a 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. Example of other libraries available for casting is Microsoft.Maui.Graphics.Point
and SkiaSharp.SKPointI
.