Create and Cast Rectangle
Rectangle
and RectangleF
are useful features provided by IronDrawing which can be used to crop any image file. Customers using rectangles from System.Drawing.Rectangle
or System.Drawing.RectangleF
can also cast them to IronSoftware.Drawing.Rectangle
and IronSoftware.Drawing.RectangleF
using the Cast
method.
Create Rectangle
& RectangleF
To create a Rectangle
, users can instantiate a new Rectangle
and provide the X and Y coordinates, as well as the width and height measurement of the Rectangle
in pixels. For example:
Similarly, for the RectangleF
class, a sample RectangleF
object can be instantiated as follows:
Cast Rectangle
& RectangleF
To cast an IronSoftware.Drawing.Rectangle
from System.Drawing.Rectangle
or an IronSoftware.Drawing.RectangleF
from System.Drawing.RectangleF
, you can use implicit conversion. Here's how you can do it:
In this example, we use implicit conversion to cast System.Drawing.Rectangle
and System.Drawing.RectangleF
to their IronSoftware.Drawing
counterparts, making it straightforward to utilize these rectangles in IronDrawing's features.