Bitmap.Clone Yöntem

Tanım

Belirtilen PixelFormatile tanımlanan bu Bitmap bölümün bir kopyasını oluşturur.

Aşırı Yüklemeler

Clone(RectangleF, PixelFormat)

Belirtilen PixelFormat sabit listesiyle tanımlanan bu Bitmap bölümün bir kopyasını oluşturur.

Clone(Rectangle, PixelFormat)

Bu Bitmap bölümün yapısı tarafından Rectangle tanımlanan ve belirtilen PixelFormat bir sabit listesiyle bir kopyasını oluşturur.

Clone(RectangleF, PixelFormat)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Belirtilen PixelFormat sabit listesiyle tanımlanan bu Bitmap bölümün bir kopyasını oluşturur.

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

Parametreler

rect
RectangleF

Bunun Bitmap kopyalanacak bölümünü tanımlar.

format
PixelFormat

PixelFormat Hedef Bitmapiçin numaralandırmayı belirtir.

Döndürülenler

Bitmap Bu yöntemin oluşturduğu.

Özel durumlar

rect kaynak bit eşlem sınırlarının dışındadır.

Yüksekliği veya genişliği rect 0'dır.

Örnekler

Aşağıdaki kod örneği, Windows Forms ile kullanılmak üzere tasarlanmıştır ve olay işleyicisinin bir parametresi olan öğesini gerektirirPaintEventArgse.Paint Kod aşağıdaki eylemleri gerçekleştirir:

  • Dosyadan bir Bitmap oluşturur.

  • Öğesinin bir bölümünü Bitmapkopyalar.

  • Kopyalanan bölümü ekrana çizer.

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

Şunlara uygulanır

Clone(Rectangle, PixelFormat)

Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs
Kaynak:
Bitmap.cs

Bu Bitmap bölümün yapısı tarafından Rectangle tanımlanan ve belirtilen PixelFormat bir sabit listesiyle bir kopyasını oluşturur.

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

Parametreler

rect
Rectangle

Bunun Bitmap kopyalanacak bölümünü tanımlar. Koordinatlar buna Bitmapgöredir.

format
PixelFormat

Yeni Bitmapiçin piksel biçimi. Bu, ile Formatbaşlayan bir değer belirtmelidir.

Döndürülenler

Bu yöntemin oluşturduğu yeni Bitmap .

Özel durumlar

rect kaynak bit eşlem sınırlarının dışındadır.

Yüksekliği veya genişliği rect 0'dır.

-veya-

PixelFormat Adı Biçim ile başlamayan bir değer belirtilir. Örneğin, belirtilmesi Gdi bir ArgumentExceptionöğesine neden olur, ancak Format48bppRgb neden olmaz.

Örnekler

Aşağıdaki kod örneği, Windows Forms ile kullanılmak üzere tasarlanmıştır ve olay işleyicisinin bir parametresi olan öğesini gerektirirPaintEventArgse.Paint Kod aşağıdaki eylemleri gerçekleştirir:

  • Dosyadan bir Bitmap oluşturur.

  • Öğesinin bir bölümünü Bitmapkopyalar.

  • Kopyalanan bölümü ekrana çizer.

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

Şunlara uygulanır