Bitmap.Cloneとは? わかりやすく解説

Bitmap.Clone メソッド (RectangleF, PixelFormat)

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

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function Clone ( _
    rect As RectangleF, _
    format As PixelFormat _
) As Bitmap
Dim instance As Bitmap
Dim rect As RectangleF
Dim format As PixelFormat
Dim returnValue As Bitmap

returnValue = instance.Clone(rect, format)
public Bitmap Clone (
    RectangleF rect,
    PixelFormat format
)
public:
Bitmap^ Clone (
    RectangleF rect, 
    PixelFormat format
)
public Bitmap Clone (
    RectangleF rect, 
    PixelFormat format
)
public function Clone (
    rect : RectangleF, 
    format : PixelFormat
) : Bitmap

パラメータ

rect

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

format

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

戻り値
このメソッドが作成する Bitmap。

例外例外
例外の種類条件

OutOfMemoryException

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

ArgumentException

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

使用例使用例

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgs の e が必要です。このコードは次のアクションを実行します。

Public 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
public 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);
}
public:
   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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Bitmap.Clone メソッド (Rectangle, PixelFormat)

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

名前空間: System.Drawing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

Public Function Clone ( _
    rect As Rectangle, _
    format As PixelFormat _
) As Bitmap
Dim instance As Bitmap
Dim rect As Rectangle
Dim format As PixelFormat
Dim returnValue As Bitmap

returnValue = instance.Clone(rect, format)
public Bitmap Clone (
    Rectangle rect,
    PixelFormat format
)
public:
Bitmap^ Clone (
    Rectangle rect, 
    PixelFormat format
)
public Bitmap Clone (
    Rectangle rect, 
    PixelFormat format
)
public function Clone (
    rect : Rectangle, 
    format : PixelFormat
) : Bitmap

パラメータ

rect

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

format

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

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

例外例外
例外の種類条件

OutOfMemoryException

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

ArgumentException

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

使用例使用例

次の例は、Windows フォームでの使用を意図してデザインされており、Paint イベント ハンドラのパラメータである PaintEventArgs の e が必要です。このコードは次のアクションを実行します。

Public 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
public 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);
}
public:
   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 );
   }
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Bitmap.Clone メソッド

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

名前 説明
Bitmap.Clone () 対象の Image の同一コピーを作成します。
Bitmap.Clone (Rectangle, PixelFormat) Rectangle 構造体と、指定された PixelFormat 列挙体で定義された、この Bitmap のセクションのコピーを作成します。
Bitmap.Clone (RectangleF, PixelFormat) 指定された PixelFormat 列挙体で定義されたこの Bitmap のセクションのコピーを作成します。
参照参照



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Bitmap.Clone」の関連用語

Bitmap.Cloneのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Bitmap.Cloneのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS