Image.RotateFlip-Methode
Diese Methode dreht und/oder kippt das Image.
Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)
Syntax
'Declaration
Public Sub RotateFlip ( _
rotateFlipType As RotateFlipType _
)
'Usage
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
)
Parameter
- rotateFlipType
Ein RotateFlipType-Member, der den Typ der Drehung bzw. des Kippens für das Bild angibt.
Rückgabewert
Diese Methode gibt keinen Wert zurück.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie die RotateFlip-Eigenschaft eines Image und die RotateFlipType-Enumeration festgelegt werden.
Dieses Beispiel ist für die Verwendung mit einem Windows Form vorgesehen, das eine PictureBox mit dem Namen PictureBox1
und eine Schaltfläche mit dem Namen Button1
enthält. Fügen Sie den Code in ein Formular ein, rufen Sie InitializeBitmap
im Konstruktor des Formulars auf, und weisen Sie Button1_Click
dem Click-Ereignis der Schaltfläche zu. Stellen Sie sicher, dass der Pfad der Bitmap auf Ihrem System gültig ist.
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
Plattformen
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 unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0