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 Form 中。 處理表單的事件 Paint ,並從事件處理方法呼叫 DrawImageUnscaled
方法 Paint ,並傳遞 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