Graphics.DrawImageUnscaledAndClipped(Image, Rectangle) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在不进行缩放的情况下绘制指定的图像,并在需要时剪辑该图像以适合指定的矩形。
public:
void DrawImageUnscaledAndClipped(System::Drawing::Image ^ image, System::Drawing::Rectangle rect);
public void DrawImageUnscaledAndClipped (System.Drawing.Image image, System.Drawing.Rectangle rect);
member this.DrawImageUnscaledAndClipped : System.Drawing.Image * System.Drawing.Rectangle -> unit
Public Sub DrawImageUnscaledAndClipped (image As Image, rect As Rectangle)
参数
例外
image
为 null
。
示例
下面的示例演示如何使用 DrawImageUnscaledAndClipped 方法。 若要运行此示例,请将其粘贴到 Windows 窗体中。 处理窗体的 Paint 事件,并从Paint事件处理方法调用 DrawImageUnscaled
方法,作为 e
PaintEventArgs传递。
private void DrawImageUnscaled(PaintEventArgs e)
{
string filepath = @"C:\Documents and Settings\All Users\Documents\" +
@"My Pictures\Sample Pictures\Water Lilies.jpg";
Bitmap bitmap1 = new Bitmap(filepath);
e.Graphics.DrawImageUnscaledAndClipped(bitmap1, new Rectangle(10,10,250,250));
}
Private Sub DrawImageUnscaled(ByVal e As PaintEventArgs)
Dim filepath As String = "C:\Documents and Settings\All Users\Documents\" _
& "My Pictures\Sample Pictures\Water Lilies.jpg"
Dim bitmap1 As New Bitmap(filepath)
e.Graphics.DrawImageUnscaledAndClipped(bitmap1, _
New Rectangle(10, 10, 250, 250))
End Sub