Export (0) Print
Expand All

Graphics.DrawImageUnscaledAndClipped Method

Draws the specified image without scaling and clips it, if necessary, to fit in the specified rectangle.

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

public void DrawImageUnscaledAndClipped (
	Image image,
	Rectangle rect
)
public void DrawImageUnscaledAndClipped (
	Image image, 
	Rectangle rect
)
public function DrawImageUnscaledAndClipped (
	image : Image, 
	rect : Rectangle
)
Not applicable.

Parameters

image

The Image to draw.

rect

The Rectangle in which to draw the image.

Exception typeCondition

ArgumentNullException

image is a null reference (Nothing in Visual Basic).

The following example demonstrates how to use the DrawImageUnscaledAndClipped method. To run this example, paste it into a Windows Form. Handle the form’s Paint event and call the DrawImageUnscaled method from the Paint event-handling method, passing e as 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));
}

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft