Bitmap.Clone メソッド

定義

指定された PixelFormat で定義されたこの Bitmap のセクションのコピーを作成します。

オーバーロード

Clone(RectangleF, PixelFormat)

指定された PixelFormat 列挙体で定義されたこの Bitmap のセクションのコピーを作成します。

Clone(Rectangle, PixelFormat)

Rectangle 構造体と、指定された PixelFormat 列挙体で定義された、この Bitmap のセクションのコピーを作成します。

Clone(RectangleF, PixelFormat)

ソース:
Bitmap.cs
ソース:
Bitmap.cs
ソース:
Bitmap.cs

指定された PixelFormat 列挙体で定義されたこの Bitmap のセクションのコピーを作成します。

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

パラメーター

rect
RectangleF

この Bitmap のコピーする部分を定義します。

format
PixelFormat

目的の BitmapPixelFormat 列挙体を指定します。

戻り値

このメソッドが作成する Bitmap

例外

rect は、ソース ビットマップ境界の外側です。

rect の高さまたは幅は 0 です。

次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • ファイルから を Bitmap 作成します。

  • Bitmap一部を複製します。

  • 複製された部分を画面に描画します。

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

適用対象

Clone(Rectangle, PixelFormat)

ソース:
Bitmap.cs
ソース:
Bitmap.cs
ソース:
Bitmap.cs

Rectangle 構造体と、指定された PixelFormat 列挙体で定義された、この Bitmap のセクションのコピーを作成します。

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

パラメーター

rect
Rectangle

この Bitmap のコピーする部分を定義します。 座標は、この Bitmap の相対座標です。

format
PixelFormat

新しい Bitmap のピクセル形式。 これは、 で Format始まる値を指定する必要があります。

戻り値

このメソッドが作成する新しい Bitmap オブジェクト。

例外

rect は、ソース ビットマップ境界の外側です。

rect の高さまたは幅は 0 です。

- または -

名前が Format で始まらない PixelFormat 値が指定されます。 たとえば、Gdi を指定すると、ArgumentException が発生しますが、Format48bppRgb を指定した場合は発生しません。

次のコード例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 コードは、次のアクションを実行します。

  • ファイルから を Bitmap 作成します。

  • Bitmap一部を複製します。

  • 複製された部分を画面に描画します。

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

適用対象