Image.RotateFlip 方法

此方法旋转、翻转或者同时旋转和翻转 Image

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public Sub RotateFlip ( _
    rotateFlipType As RotateFlipType _
)
用法
Dim instance As Image
Dim rotateFlipType As RotateFlipType

instance.RotateFlip(rotateFlipType)
public void RotateFlip (
    RotateFlipType rotateFlipType
)
public:
void RotateFlip (
    RotateFlipType rotateFlipType
)
public void RotateFlip (
    RotateFlipType rotateFlipType
)
public function RotateFlip (
    rotateFlipType : RotateFlipType
)

参数

  • rotateFlipType
    RotateFlipType 成员,指定要应用于该图像的旋转和翻转的类型。

返回值

此方法不返回值。

示例

下面的代码示例演示如何设置 ImageRotateFlip 属性和 RotateFlipType 枚举。

此示例旨在用于包含名为 PictureBox1PictureBox 和名为 Button1 的按钮的 Windows 窗体。将该代码粘贴到一个窗体中,在该窗体的构造函数中调用 InitializeBitmap,并将 Button1_Click 与按钮的 Click 事件关联。请确保位图的文件路径在您的系统上是有效的。

Dim bitmap1 As Bitmap

Private Sub InitializeBitmap()
    Try
        bitmap1 = CType(Bitmap.FromFile("C:\Documents and Settings\All Users\" _
            & "Documents\My Music\music.bmp"), Bitmap)
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize
        PictureBox1.Image = bitmap1
    Catch ex As System.IO.FileNotFoundException
        MessageBox.Show("There was an error. Check the path to the bitmap.")
    End Try


End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click

    If Not bitmap1 Is Nothing Then
        bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY)
        PictureBox1.Image = bitmap1
    End If

End Sub
Bitmap bitmap1;

private void InitializeBitmap()
{
    try
    {
        bitmap1 = (Bitmap)Bitmap.FromFile(@"C:\Documents and Settings\" + 
            @"All Users\Documents\My Music\music.bmp");
        PictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
        PictureBox1.Image = bitmap1;
    }
    catch(System.IO.FileNotFoundException)
    {
        MessageBox.Show("There was an error." + 
            "Check the path to the bitmap.");
    }


}

private void Button1_Click(System.Object sender, System.EventArgs e)
{

    if (bitmap1 != null)
    {
        bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY);
        PictureBox1.Image = bitmap1;
    }

}
Bitmap^ bitmap1;
void InitializeBitmap()
{
   try
   {
      bitmap1 = dynamic_cast<Bitmap^>(Bitmap::FromFile( "C:\\Documents and Settings\\"
      "All Users\\Documents\\My Music\\music.bmp" ));
      PictureBox1->SizeMode = PictureBoxSizeMode::AutoSize;
      PictureBox1->Image = bitmap1;
   }
   catch ( System::IO::FileNotFoundException^ ) 
   {
      MessageBox::Show( "There was an error."
      "Check the path to the bitmap." );
   }

}

void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   if ( bitmap1 != nullptr )
   {
      bitmap1->RotateFlip( RotateFlipType::Rotate180FlipY );
      PictureBox1->Image = bitmap1;
   }
}
private Bitmap bitmap1;

private void InitializeBitmap()
{
    try {
        bitmap1 = ((Bitmap)(Bitmap.FromFile(("C:\\Documents and Settings\\"
            + "All Users\\Documents\\My Music\\music.bmp"))));
        pictureBox1.set_SizeMode(PictureBoxSizeMode.AutoSize);
        pictureBox1.set_Image(bitmap1);
    }
    catch (System.IO.FileNotFoundException exp) {
        MessageBox.Show(("There was an error." 
            + "Check the path to the bitmap."));
    }
} //InitializeBitmap

private void button1_Click(Object sender, System.EventArgs e)
{
    if (bitmap1 != null) {
        bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY);
        pictureBox1.set_Image(bitmap1);
    }
} //button1_Click

平台

Windows 98、Windows 2000 SP4、Windows Millennium Edition、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Image 类
Image 成员
System.Drawing 命名空间