Bitmap.Clone Methode

Definition

Erstellt eine Kopie des Abschnitts dieser Bitmap definierten mit einem angegebenen PixelFormat.

Überlädt

Name Beschreibung
Clone(RectangleF, PixelFormat)

Erstellt eine Kopie des Abschnitts dieser Bitmap Definierten mit einer angegebenen PixelFormat Aufzählung.

Clone(Rectangle, PixelFormat)

Erstellt eine Kopie des Abschnitts dieser Bitmap definierten Struktur Rectangle und mit einer angegebenen PixelFormat Enumeration.

Clone(RectangleF, PixelFormat)

Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs

Erstellt eine Kopie des Abschnitts dieser Bitmap Definierten mit einer angegebenen PixelFormat Aufzählung.

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 Teil.Bitmap

format
PixelFormat

Gibt die PixelFormat Aufzählung für das Ziel Bitmapan.

Gibt zurück

Die Bitmap Methode, die von dieser Methode erstellt wird.

Ausnahmen

rect außerhalb der Quellbitmapgrenzen.

Die Höhe oder Breite von rect 0.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des ereignishandlers Paint handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine Bitmap Aus einer Datei.

  • Klont einen Teil davon 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
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs
Quelle:
Bitmap.cs

Erstellt eine Kopie des Abschnitts dieser Bitmap definierten Struktur Rectangle und 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 Teil.Bitmap Koordinaten sind relativ zu diesem Bitmap.

format
PixelFormat

Das Pixelformat für das neue Bitmap. Dies muss einen Wert angeben, der mit Format.

Gibt zurück

Die neue Bitmap Methode, die von dieser Methode erstellt wird.

Ausnahmen

rect außerhalb der Quellbitmapgrenzen.

Die Höhe oder Breite von rect 0.

-oder-

Es wird ein PixelFormat Wert angegeben, dessen Name nicht mit "Format" beginnt. Die Angabe Gdi führt z. B. zu einer ArgumentException, aber Format48bppRgb nicht.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des ereignishandlers Paint handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine Bitmap Aus einer Datei.

  • Klont einen Teil davon 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: