在 .NET 中,您可以在没有外部库的情况下进行旋转;如果您可以在 .NET 中编写代码并在此处使用 .NET Framework 原语,例如(C#):
public static Bitmap RotateImage(Image image, PointF offset, float angle)
{
int R1, R2;
R1 = R2 = 0;
if (image.Width > image.Height)
R2 = image.Width - image.Height;
else
R1 = image.Height-image.Width;
if (image == null)
throw new ArgumentNullException("image");
//create a new empty bitmap to hold rotated image
Bitmap rotatedBmp = new Bitmap(image.Width +R1+40, image.Height+R2+40);
rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
//make a graphics object from the empty bitmap
Graphics g = Graphics.FromImage(rotatedBmp);
//Put the rotation point in the center of the image
g.TranslateTransform(offset.X + R1/2+20, offset.Y + R2/2+20);
//rotate the image
g.RotateTransform(angle);
//move the image back
g.TranslateTransform(-offset.X - R1 / 2-20, -offset.Y - R2 / 2-20);
//draw passed in image onto graphics object
g.DrawImage(image, new PointF(R1 / 2+20, R2 / 2+20));
return rotatedBmp;
}