Image.RotateFlip(RotateFlipType) Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Draait, spiegelt of draait en spiegelt de 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)
Parameters
- rotateFlipType
- RotateFlipType
Een RotateFlipType lid dat het type draaiing aangeeft en spiegelt om toe te passen op de afbeelding.
Voorbeelden
In het volgende codevoorbeeld ziet u hoe u de RotateFlip methode aanroept op een Image en de RotateFlipType opsomming.
Dit voorbeeld is ontworpen voor gebruik met een Windows Formulier met een PictureBox met de naam PictureBox1 en een knop met de naam Button1. Plak de code in een formulier, roep InitializeBitmap aan vanuit de constructor van het formulier en koppel deze aan Button1_Click de gebeurtenis van Click de knop. Zorg ervoor dat het bestandspad naar de bitmap geldig is op uw systeem.
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
Opmerkingen
De RotateFlip methode draait de afbeelding rechtsom.
Als u op een afbeelding wilt tekenen zodra deze is gedraaid, moet u altijd een nieuw grafische object uit de afbeelding ophalen, anders kan er een uitzondering optreden.