UID | title | description | helpviewer_keywords | old-location | tech.root | ms.assetid | ms.date | ms.keywords | req.header | req.include-header | req.target-type | req.target-min-winverclnt | req.target-min-winversvr | req.kmdf-ver | req.umdf-ver | req.ddi-compliance | req.unicode-ansi | req.idl | req.max-support | req.namespace | req.assembly | req.type-library | req.lib | req.dll | req.irql | targetos | req.typenames | req.redist | req.product | ms.custom | f1_keywords | dev_langs | topic_type | api_type | api_location | api_name | ||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NF:gdiplusgraphics.Graphics.DrawImage(Image,constRectF&,REAL,REAL,REAL,REAL,Unit,constImageAttributes,DrawImageAbort,VOID) |
Graphics::DrawImage(IN Image,IN const RectF &,IN REAL,IN REAL,IN REAL,IN REAL,IN Unit,IN const ImageAttributes,IN DrawImageAbort,IN VOID) (gdiplusgraphics.h) |
The Graphics::DrawImage method draws an image. (overload 12/14) |
|
gdiplus\_gdiplus_CLASS_Graphics_DrawImage_Image_image_RectF_destRect_REAL_srcx_REAL_srcy_REAL_srcwidth_REAL_.htm |
gdiplus |
VS|gdicpp|~\gdiplus\gdiplusreference\classes\graphicsclass\graphicsmethods\graphicsdrawimagemethods\drawimage_96imageimage_rectfampdestrect_realsrcx_r.htm |
12/05/2018 |
DrawImage, DrawImage method [GDI+], DrawImage method [GDI+],Graphics class, Graphics class [GDI+],DrawImage method, Graphics.DrawImage, Graphics.DrawImage(IN Image,IN const RectF &,IN REAL,IN REAL,IN REAL,IN REAL,IN Unit,IN const ImageAttributes,IN DrawImageAbort,IN VOID), Graphics.DrawImage(Image*,const RectF&,REAL,REAL,REAL,REAL,Unit,ImageAttributes*,DrawImageAbort,VOID*), Graphics::DrawImage, Graphics::DrawImage(IN Image,IN const RectF &,IN REAL,IN REAL,IN REAL,IN REAL,IN Unit,IN const ImageAttributes,IN DrawImageAbort,IN VOID), _gdiplus_CLASS_Graphics_DrawImage_Image_image_RectF_destRect_REAL_srcx_REAL_srcy_REAL_srcwidth_REAL_, gdiplus._gdiplus_CLASS_Graphics_DrawImage_Image_image_RectF_destRect_REAL_srcx_REAL_srcy_REAL_srcwidth_REAL_ |
gdiplusgraphics.h |
Gdiplus.h |
Windows |
Windows XP, Windows 2000 Professional [desktop apps only] |
Windows 2000 Server [desktop apps only] |
Gdiplus.lib |
Gdiplus.dll |
Windows |
GDI+ 1.0 |
19H1 |
|
|
|
|
|
|
Graphics::DrawImage(IN Image,IN const RectF &,IN REAL,IN REAL,IN REAL,IN REAL,IN Unit,IN const ImageAttributes,IN DrawImageAbort,IN VOID)
The Graphics::DrawImage method draws an image.
Type: Image*
Pointer to an Image object that specifies the source image.
Type: const RectF
Reference to a rectangle that bounds the drawing area for the image.
Type: REAL
Real number that specifies the x-coordinate of the upper-left corner of the portion of the source image to be drawn.
Type: REAL
Real number that specifies the y-coordinate of the upper-left corner of the portion of the source image to be drawn.
Type: REAL
Real number that specifies the width of the portion of the source image to be drawn.
Type: REAL
Real number that specifies the height of the portion of the source image to be drawn.
Type: Unit
Element of the Unit enumeration that specifies the unit of measure for the image. The default value is UnitPixel.
Type: ImageAttributes*
Pointer to an ImageAttributes object that specifies the color and size attributes of the image to be drawn. The default value is NULL.
Type: DrawImageAbort
Callback method used to cancel the drawing in progress. The default value is NULL.
Type: VOID*
Pointer to additional data used by the method specified by the callback parameter. The default value is NULL.
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.
The portion of the source image to be drawn is scaled to fit the rectangle.
The following example draws the original source image and then draws a portion of the image in a specified rectangle.
VOID Example_DrawImage6(HDC hdc)
{
Graphics graphics(hdc);
// Create an Image object.
Image image(L"pattern.png");
// Draw the original source image.
graphics.DrawImage(&image, 10, 10);
// Define the portion of the image to draw.
REAL srcX = 70.0f;
REAL srcY = 20.0f;
REAL srcWidth = 100.0f;
REAL srcHeight = 100.0f;
// Create a RectF object that specifies the destination of the image.
RectF destRect(200.0f, 10.0f, <REAL>image.GetWidth(), <REAL>image.GetHeight());
// Create an ImageAttributes object that specifies a recoloring from red to blue.
ImageAttributes remapAttributes;
ColorMap redToBlue;
redToBlue.oldColor = Color(255, 255, 0, 0);
redToBlue.newColor = Color(255, 0, 0, 255);
remapAttributes.SetRemapTable(1, &redToBlue);
// Draw the resized image.
graphics.DrawImage(
&image,
destRect,
srcX,
srcY,
srcWidth,
srcHeight,
UnitPixel,
&remapAttributes,
NULL,
NULL);
}
The following illustration shows the output of the preceding code.
Drawing, Positioning, and Cloning Images