C# 如何将System.Drawing.Image旋转x度?

C# 如何将System.Drawing.Image旋转x度?,c#,gdi+,C#,Gdi+,我需要将汽车图像旋转X度,以指示行驶方向。现在我有了这个工作代码,可以在GDI+曲面上绘制图像 int hdc = Display.hDC; IntPtr p = new IntPtr(hdc); graphics = Graphics.FromHdc(p); newImage = Image.FromFile(carImage); System.Drawing.Point ulCorner = new System.Drawing.Point(x - 25, y -15); //graphi

我需要将汽车图像旋转X度,以指示行驶方向。现在我有了这个工作代码,可以在GDI+曲面上绘制图像

int hdc = Display.hDC;
IntPtr p = new IntPtr(hdc);
graphics = Graphics.FromHdc(p);
newImage = Image.FromFile(carImage);
System.Drawing.Point ulCorner = new System.Drawing.Point(x - 25, y -15);

//graphics.RotateTransform(45); //tried this line, when i used it, it drew nothing.
graphics.DrawImage(newImage, ulCorner);

如何旋转X度

以下是如何旋转图像

 //move rotation point to center of image
  graphics.TranslateTransform((float)newImage.Width/2,(float)newImage.Height / 2);
  //rotate
  graphics.RotateTransform(angle);
  //move image back
  graphics.TranslateTransform(-(float)newImage.Width/2,-(float)newImage.Height / 2);

我试过这个代码,但屏幕上什么也没画出来。我不知道这是否相关,但我正在将WPF与winformshost以及ESRI的ArcEngine应用程序一起使用。