Bitmap.Clone Méthode

Définition

Crée une copie de la section de cette Bitmap section définie avec un élément spécifié PixelFormat.

Surcharges

Nom Description
Clone(RectangleF, PixelFormat)

Crée une copie de la section de cette Bitmap section définie avec une énumération spécifiée PixelFormat .

Clone(Rectangle, PixelFormat)

Crée une copie de la section de cette Bitmap section définie par Rectangle structure et avec une énumération spécifiée PixelFormat .

Clone(RectangleF, PixelFormat)

Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs

Crée une copie de la section de cette Bitmap section définie avec une énumération spécifiée PixelFormat .

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

Paramètres

rect
RectangleF

Définit la partie de cette Bitmap opération à copier.

format
PixelFormat

Spécifie l’énumération PixelFormat pour la destination Bitmap.

Retours

Cette Bitmap méthode crée.

Exceptions

rect est en dehors des limites bitmap sources.

La hauteur ou la largeur de rect 0.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms, et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. Le code effectue les actions suivantes :

  • Crée un Bitmap fichier à partir d’un fichier.

  • Clone une partie de ce Bitmap.

  • Dessine la partie cloné à l’écran.

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

S’applique à

Clone(Rectangle, PixelFormat)

Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs
Source:
Bitmap.cs

Crée une copie de la section de cette Bitmap section définie par Rectangle structure et avec une énumération spécifiée PixelFormat .

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

Paramètres

rect
Rectangle

Définit la partie de cette Bitmap opération à copier. Les coordonnées sont relatives à ceci Bitmap.

format
PixelFormat

Format de pixel pour le nouveau Bitmap. Cela doit spécifier une valeur qui commence par Format.

Retours

Nouveau Bitmap créé par cette méthode.

Exceptions

rect est en dehors des limites bitmap sources.

La hauteur ou la largeur de rect 0.

- ou -

Une PixelFormat valeur est spécifiée dont le nom ne commence pas par Format. Par exemple, la spécification Gdi entraîne une ArgumentExceptionerreur, mais Format48bppRgb pas.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms, et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d’événements Paint. Le code effectue les actions suivantes :

  • Crée un Bitmap fichier à partir d’un fichier.

  • Clone une partie de ce Bitmap.

  • Dessine la partie cloné à l’écran.

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

S’applique à