android bitmap.clone,Bitmap.Clone 方法 (System.Drawing) | Microsoft Docs

Creates a copy of the section of this Bitmap defined by Rectangle structure and with a specified PixelFormat enumeration.

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

参数

定义此 Bitmap 中要复制的部分。Defines the portion of this Bitmap to copy. 坐标相对于此 Bitmap。Coordinates are relative to this Bitmap.

新 Bitmap 的像素格式。The pixel format for the new Bitmap. 这必须指定以格式开头的值。This must specify a value that begins with Format.

返回

此方法创建的新 Bitmap。The new Bitmap that this method creates.

例外

rect 位于源位图边界之外。rect is outside of the source bitmap bounds.

rect 的高度或宽度为 0。The height or width of rect is 0.

- 或 --or-

已指定名称不以格式开头的 PixelFormat 值。A PixelFormat value is specified whose name does not start with Format. For example, specifying Gdi will cause an ArgumentException, but Format48bppRgb will not.

示例

下面的代码示例旨在与 Windows 窗体一起使用,并且它需要作为 PaintEventArgs e Paint 事件处理程序的参数。The following code example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 此代码执行以下操作:The code performs the following actions:

Bitmap从文件创建。Creates a Bitmap from a file.

Clones a portion of that Bitmap.

将克隆的部分绘制到屏幕上。Draws the cloned portion to the screen.

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

适用于

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值