我有一个位图,上面绘制了一个 Rectangle 对象。我希望能够 RotateFlip 位图并调整 Rectangle 的 x、y、宽度和高度,使其在每次旋转或翻转后与位图对齐。
例如,如果我有一个 1000 x 800 像素的位图,我可能会在其上绘制一个具有指定点和大小的 Rectangle 对象。
示例代码:
// A bitmap that's 1000x800 size
Bitmap bitmap = new Bitmap(fileName);
// Any arbitrary rectangle that can be drawn inside the bitmap boundaries
Rectangle rect = new Rectangle(200, 200, 100, 100);
bitmap.RotateFlip(rotateFlipType);
switch (rotateFlipType)
{
case Rotate90FlipNone:
// Adjust rectangle to match new bitmap orientation
rect = new Rectangle(?, ?, ?, ?);
break;
case RotateNoneFlip180:
rect = new Rectangle(?, ?, ?, ?);
break;
// ... etc.
}