Bitmap.Clone Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Erstellt eine Kopie des Abschnitts dieser Bitmap, die mit einem angegebenen PixelFormat definiert wird.
Überlädt
Clone(RectangleF, PixelFormat) |
Erstellt eine Kopie des Abschnitts dieser Bitmap, die mit einer angegebenen PixelFormat-Enumeration definiert wird. |
Clone(Rectangle, PixelFormat) |
Erstellt eine Kopie des Abschnitts dieser Bitmap, die durch die Rectangle-Struktur definiert wird, mit einer angegebenen PixelFormat-Enumeration. |
Clone(RectangleF, PixelFormat)
- Quelle:
- Bitmap.cs
- Quelle:
- Bitmap.cs
- Quelle:
- Bitmap.cs
Erstellt eine Kopie des Abschnitts dieser Bitmap, die mit einer angegebenen PixelFormat-Enumeration definiert wird.
public:
System::Drawing::Bitmap ^ Clone(System::Drawing::RectangleF rect, System::Drawing::Imaging::PixelFormat format);
public System.Drawing.Bitmap Clone (System.Drawing.RectangleF rect, System.Drawing.Imaging.PixelFormat format);
override this.Clone : System.Drawing.RectangleF * System.Drawing.Imaging.PixelFormat -> System.Drawing.Bitmap
Public Function Clone (rect As RectangleF, format As PixelFormat) As Bitmap
Parameter
- rect
- RectangleF
Definiert den zu kopierenden Bereich dieser Bitmap.
- format
- PixelFormat
Gibt die PixelFormat-Enumeration für die Ziel-Bitmap an.
Gibt zurück
Die Bitmap, die von dieser Methode erstellt wird.
Ausnahmen
rect
ist außerhalb der Quellbitmapgrenzen.
Die Höhe oder die Breite von rect
ist 0.
Beispiele
Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse
, was ein Parameter des Paint Ereignishandlers ist. Der Code führt die folgenden Aktionen aus:
Erstellt eine Bitmap aus einer Datei.
Klont einen Teil dieser Bitmap.
Zeichnet den geklonten Teil auf den Bildschirm.
private:
void Clone_Example2( PaintEventArgs^ e )
{
// Create a Bitmap object from a file.
Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" );
// Clone a portion of the Bitmap object.
RectangleF cloneRect = RectangleF(0,0,100,100);
System::Drawing::Imaging::PixelFormat format = myBitmap->PixelFormat;
Bitmap^ cloneBitmap = myBitmap->Clone( cloneRect, format );
// Draw the cloned portion of the Bitmap object.
e->Graphics->DrawImage( cloneBitmap, 0, 0 );
}
private void Clone_Example2(PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Clone a portion of the Bitmap object.
RectangleF cloneRect = new RectangleF(0, 0, 100, 100);
System.Drawing.Imaging.PixelFormat format =
myBitmap.PixelFormat;
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
// Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0);
}
Private Sub Clone_Example2(ByVal e As PaintEventArgs)
' Create a Bitmap object from a file.
Dim myBitmap As New Bitmap("Grapes.jpg")
' Clone a portion of the Bitmap object.
Dim cloneRect As New RectangleF(0, 0, 100, 100)
Dim format As PixelFormat = myBitmap.PixelFormat
Dim cloneBitmap As Bitmap = myBitmap.Clone(cloneRect, format)
' Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0)
End Sub
Gilt für:
Clone(Rectangle, PixelFormat)
- Quelle:
- Bitmap.cs
- Quelle:
- Bitmap.cs
- Quelle:
- Bitmap.cs
Erstellt eine Kopie des Abschnitts dieser Bitmap, die durch die Rectangle-Struktur definiert wird, mit einer angegebenen PixelFormat-Enumeration.
public:
System::Drawing::Bitmap ^ Clone(System::Drawing::Rectangle rect, System::Drawing::Imaging::PixelFormat format);
public System.Drawing.Bitmap Clone (System.Drawing.Rectangle rect, System.Drawing.Imaging.PixelFormat format);
override this.Clone : System.Drawing.Rectangle * System.Drawing.Imaging.PixelFormat -> System.Drawing.Bitmap
Public Function Clone (rect As Rectangle, format As PixelFormat) As Bitmap
Parameter
- rect
- Rectangle
Definiert den zu kopierenden Bereich dieser Bitmap. Die Koordinaten sind relativ zu dieser Bitmap.
- format
- PixelFormat
Das Pixelformat für die neue Bitmap. Dies muss einen Wert angeben, der mit Format
beginnt.
Gibt zurück
Das neue Bitmap, das von dieser Methode erstellt wird.
Ausnahmen
rect
ist außerhalb der Quellbitmapgrenzen.
Die Höhe oder die Breite von rect
ist 0.
- oder -
Ein PixelFormat-Wert wird angegeben, dessen Name nicht mit Format beginnt. Die Angabe von Gdi verursacht z. B. eine ArgumentException, Format48bppRgb hingegen nicht.
Beispiele
Das folgende Codebeispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse
, was ein Parameter des Paint Ereignishandlers ist. Der Code führt die folgenden Aktionen aus:
Erstellt eine Bitmap aus einer Datei.
Klont einen Teil dieser Bitmap.
Zeichnet den geklonten Teil auf den Bildschirm.
private:
void Clone_Example1( PaintEventArgs^ e )
{
// Create a Bitmap object from a file.
Bitmap^ myBitmap = gcnew Bitmap( "Grapes.jpg" );
// Clone a portion of the Bitmap object.
Rectangle cloneRect = Rectangle(0,0,100,100);
System::Drawing::Imaging::PixelFormat format = myBitmap->PixelFormat;
Bitmap^ cloneBitmap = myBitmap->Clone( cloneRect, format );
// Draw the cloned portion of the Bitmap object.
e->Graphics->DrawImage( cloneBitmap, 0, 0 );
}
private void Clone_Example1(PaintEventArgs e)
{
// Create a Bitmap object from a file.
Bitmap myBitmap = new Bitmap("Grapes.jpg");
// Clone a portion of the Bitmap object.
Rectangle cloneRect = new Rectangle(0, 0, 100, 100);
System.Drawing.Imaging.PixelFormat format =
myBitmap.PixelFormat;
Bitmap cloneBitmap = myBitmap.Clone(cloneRect, format);
// Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0);
}
Private Sub Clone_Example1(ByVal e As PaintEventArgs)
' Create a Bitmap object from a file.
Dim myBitmap As New Bitmap("Grapes.jpg")
' Clone a portion of the Bitmap object.
Dim cloneRect As New Rectangle(0, 0, 100, 100)
Dim format As PixelFormat = myBitmap.PixelFormat
Dim cloneBitmap As Bitmap = myBitmap.Clone(cloneRect, format)
' Draw the cloned portion of the Bitmap object.
e.Graphics.DrawImage(cloneBitmap, 0, 0)
End Sub
Gilt für:
Feedback
https://aka.ms/ContentUserFeedback.
Bald verfügbar: Im Laufe des Jahres 2024 werden wir GitHub-Issues stufenweise als Feedbackmechanismus für Inhalte abbauen und durch ein neues Feedbacksystem ersetzen. Weitere Informationen finden Sie unterFeedback senden und anzeigen für