I'm not sure if the question is too trivial but, I need to use the following overload of the method Graphics.DrawImage
:
public void DrawImage(
Image image,
PointF[] destPoints,
RectangleF srcRect,
GraphicsUnit srcUnit,
ImageAttributes imageAttr
)
I have a RectangleF
as destination rectangle, so I need to convert the RectangleF
to PointF[]
but the example in the MSDN confused me a little bit because it only uses three points to define a parallelogram.
How could I do it?
Thanks in advance
Ok, I found it in the MSDN:
The destPoints parameter specifies three points of a parallelogram. The three PointF structures represent the upper-left, upper-right, and lower-left corners of the parallelogram. The fourth point is extrapolated from the first three to form a parallelogram.
So you can construct your point array in the following way:
private PointF[] GetPoints(RectangleF rectangle)
{
return new PointF[3]
{
new PointF(rectangle.Left, rectangle.Top),
new PointF(rectangle.Right, rectangle.Top),
new PointF(rectangle.Left, rectangle.Bottom)
};
}