Graphics.DrawImage(Image*, REAL, REAL, REAL, REAL) method
Applies to: desktop apps only
The Graphics::DrawImage method draws an image.
Syntax
Status DrawImage(
[in] Image *image,
[in] REAL x,
[in] REAL y,
[in] REAL width,
[in] REAL height
);
Parameters
image [in]
Type: Image*Pointer to an Image object that specifies the source image.
x [in]
Type: REALReal number that specifies the x-coordinate of the upper-left corner of the destination rectangle at which to draw the image.
y [in]
Type: REALReal number that specifies the y-coordinate of the upper-left corner of the destination rectangle at which to draw the image.
width [in]
Type: REALReal number that specifies the width of the destination rectangle at which to draw the image.
height [in]
Type: REALReal number that specifies the height of the destination rectangle at which to draw the image.
Return value
Type:
Type: Status****
If the method succeeds, it returns Ok, which is an element of the Status enumeration.
If the method fails, it returns one of the other elements of the Status enumeration.
Examples
The following example draws an image.
VOID Example_DrawImage16(HDC hdc)
{
Graphics graphics(hdc);
// Create an Image object.
Image image(L"climber.jpg");
// Draw the original source image.
graphics.DrawImage(&image, 10, 10);
// Draw the scaled image.
graphics.DrawImage(&image, 200.0f, 50.0f, 150.0f, 175.0f);
}
The following illustration shows the output of the preceding code.
.png)
Requirements
Minimum supported client |
Windows XP, Windows 2000 Professional |
Minimum supported server |
Windows 2000 Server |
Product |
GDI+ 1.0 |
Header |
Gdiplusgraphics.h (include Gdiplus.h) |
Library |
Gdiplus.lib |
DLL |
Gdiplus.dll |
See also
Loading and Displaying Bitmaps
Drawing, Positioning, and Cloning Images
Send comments about this topic to Microsoft
Build date: 3/6/2012