我不确定这个问题是否太微不足道,但是,我需要使用 following方法 Graphics.DrawImage
的重载:
public void DrawImage(
Image image,
PointF[] destPoints,
RectangleF srcRect,
GraphicsUnit srcUnit,
ImageAttributes imageAttr
)
我有一个 RectangleF
作为目标矩形,因此我需要将 RectangleF
转换为 PointF[]
但 example in the MSDN让我有点困惑,因为它只使用三个点来定义平行四边形。
我该怎么做?
提前致谢
最佳答案
好的,我在 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.
因此您可以通过以下方式构建点数组:
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)
};
}
关于c# - 如何将 RectangleF 转换为 PointF[] 进行绘图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9402224/