Makes a deep copy of the current Bitmap.
Syntax

[C#]

virtual Image Clone();
Bitmap Clone(RectangleF rect, PixelFormat format);

[Visual Basic]

Overidable Function Clone() As Image
Function Clone(rect As RectangleF, format As PixelFormat) As Bitmap
Params
Name Description
rect The section of the Bitmap that is required.
format The PixelFormat for the new Bitmap.
Notes

None.

Example

[C#]

using (Bitmap pic = (Bitmap)Bitmap.FromFile(Server.MapPath("rez/joel-filipe-_AjqGGafofE-unsplash.jpg"))) {
  RectangleF rect = pic.Bounds;
  rect.Inflate(-50, -100);
  using (Bitmap crop = pic.Clone(rect, PixelFormat.Format32bppArgb)) {
    crop.Save(Server.MapPath("IG8_Bitmap_Clone.jpg"));
  }
}


Here we make a clone of a portion of an existing Bitmap. The input and output files are shown below.


joel-filipe-_AjqGGafofE-unsplash.jpg


IG8_Bitmap_Clone.jpg