Reputation: 31847
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
Upvotes: 2
Views: 3826
Reputation: 31847
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)
};
}
Upvotes: 3
Reputation: 13965
Couldn't you create it by just constructing the array?
(From memory) Where d is the destination RectangleF:
destPoints[] = new PointF[4] { new PointF(d.Left, d.Top), new PointF(d.Right, d.Top), new PointF(d.Right, d.Bottom), new PointF(d.Left, d.Bottom) };
Upvotes: 2