語言

Graphics.DrawImageUnscaledAndClipped(Image, Rectangle) 方法

定義

繪製指定的影像而不進行縮放,必要時將其裁剪以符合指定的矩形。

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
Image

畫 Image 畫。

rect
Rectangle

畫出圖像的地點 Rectangle 。

例外狀況

image 是 null。

範例

以下範例示範如何使用此 DrawImageUnscaledAndClipped 方法。 要執行這個範例,請將它貼到 Windows 表單中。 處理表單的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

適用於