Image.RotateFlip(RotateFlipType) Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Fait pivoter, retourner ou faire pivoter et retourner le Image.
public:
void RotateFlip(System::Drawing::RotateFlipType rotateFlipType);
public void RotateFlip(System.Drawing.RotateFlipType rotateFlipType);
member this.RotateFlip : System.Drawing.RotateFlipType -> unit
Public Sub RotateFlip (rotateFlipType As RotateFlipType)
Paramètres
- rotateFlipType
- RotateFlipType
Membre RotateFlipType qui spécifie le type de rotation et de retournement à appliquer à l’image.
Exemples
L’exemple de code suivant montre comment appeler la RotateFlip méthode sur une Image énumération et une RotateFlipType énumération.
Cet exemple est conçu pour être utilisé avec un formulaire Windows qui contient un PictureBox nommé PictureBox1 et un bouton nommé Button1. Collez le code dans un formulaire, appelez InitializeBitmap le constructeur du formulaire et associez-le Button1_Click à l’événement du Click bouton. Vérifiez que le chemin d’accès au fichier de la bitmap est valide sur votre système.
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
Remarques
La RotateFlip méthode fait pivoter l’image dans le sens des aiguilles d’une montre.
Si vous souhaitez dessiner sur une image une fois qu’elle a été pivotée, vous devez toujours récupérer un nouvel objet graphique à partir de l’image, sinon une exception peut se produire.