共用方式為


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

例外狀況

imagenull

範例

下列範例示範如何使用 DrawImageUnscaledAndClipped 方法。 若要執行此範例,請將它貼到 Windows Form 中。 處理表單的事件 Paint ,並從事件處理方法呼叫 DrawImageUnscaled 方法 Paint ,並傳遞 ePaintEventArgs

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

適用於