3

C# Windows フォーム アプリケーションの if ループで画像を回転させるこのコードがありますが、フォームはフォーム出力に何も表示しません。

誰でも助けることができますか?

this.splitContainer1.Panel2.Controls.Add(PictureBox1);
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
PictureBox1.Image = bitmap; //Image.FromFile(@"C:\image.jpg");
PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
PictureBox1.Image = (Image)(RotateImg(bitmap, 30.0f, Color.Transparent));
4

2 に答える 2

5

一般的な角度で画像を回転する必要がある場合は、RotateFlip メソッドを簡単に使用できます。私のサンプルコードを見てください:

string fileName = "somefile.png";
System.Drawing.Imaging.ImageFormat imageFormat = System.Drawing.Imaging.ImageFormat.Png;
Bitmap bitmap =(Bitmap)Bitmap.FromFile(fileName );
//this will rotate image to the left...
bitmap.RotateFlip(RotateFlipType.Rotate270FlipNone);
//lets save result back to file...
bitmap.Save(fileName, imageFormat);
bitmap.Dispose();

以上です、お役に立てば幸いです。

于 2012-06-13T08:51:24.453 に答える
4

これを試して:

PictureBox1.Images.RotateFlip(RotateFlipType.Rotate180FlipX);
PictureBox1.Refresh();
于 2016-04-27T10:28:04.273 に答える