RotateFlipType 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定旋轉影像的量,以及用來翻轉影像的座標軸。
public enum class RotateFlipType
public enum RotateFlipType
type RotateFlipType =
Public Enum RotateFlipType
- 繼承
欄位
| 名稱 | 值 | Description |
|---|---|---|
| Rotate180FlipXY | 0 | 規定先順時針旋轉180度,接著水平與垂直翻轉。 |
| RotateNoneFlipNone | 0 | 規定不需順時針旋轉,也不需翻轉。 |
| Rotate270FlipXY | 1 | 規定順時針旋轉270度,接著水平與垂直翻轉。 |
| Rotate90FlipNone | 1 | 規定順時針旋轉90度且不翻轉。 |
| Rotate180FlipNone | 2 | 規定順時針旋轉180度且不翻轉。 |
| RotateNoneFlipXY | 2 | 規定不進行順時針旋轉後接水平與垂直翻轉。 |
| Rotate270FlipNone | 3 | 規定順時針旋轉270度且不翻轉。 |
| Rotate90FlipXY | 3 | 規定先順時針旋轉90度,接著進行水平與垂直翻轉。 |
| Rotate180FlipY | 4 | 規定順時針旋轉180度,接著垂直翻轉。 |
| RotateNoneFlipX | 4 | 規定不進行順時針旋轉後再進行水平翻轉。 |
| Rotate270FlipY | 5 | 規定順時針旋轉270度後進行垂直翻轉。 |
| Rotate90FlipX | 5 | 規定順時針旋轉90度後進行水平翻轉。 |
| Rotate180FlipX | 6 | 規定順時針旋轉180度後進行水平翻轉。 |
| RotateNoneFlipY | 6 | 規定不需順時針旋轉後再垂直翻轉。 |
| Rotate270FlipX | 7 | 規定順時針旋轉270度,接著水平翻轉。 |
| Rotate90FlipY | 7 | 規定順時針旋轉90度後進行垂直翻轉。 |
範例
以下程式碼範例示範如何設定 RotateFlip 和 ImageRotateFlipType 枚舉的屬性。
此範例設計用於包含一個名為 PictureBoxPictureBox1 的 Windows 表單,以及一個名為 Button1 的按鈕。 將程式碼貼到表單中,從表單的建構子或InitializeBitmap事件處理方法呼叫Load,並與按鈕的Button1_Click事件關聯Click。 確保你的系統中位圖的檔案路徑是有效的。
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;
}
}
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;
}
}
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 bitmap1 IsNot Nothing Then
bitmap1.RotateFlip(RotateFlipType.Rotate180FlipY)
PictureBox1.Image = bitmap1
End If
End Sub
備註
影像會順時針旋轉。