Skip to content

Latest commit

 

History

History
258 lines (139 loc) · 7.95 KB

nf-gdiplusgraphics-graphics-drawimage(image_constrectf__real_real_real_real_unit_constimageattributes_drawimageabort_void).md

File metadata and controls

258 lines (139 loc) · 7.95 KB
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)
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_
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
gdiplusgraphics/Graphics::DrawImage
c++
APIRef
kbSyntax
COM
Gdiplus.dll
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)

-description

The Graphics::DrawImage method draws an image.

-parameters

-param image [in]

Type: Image*

Pointer to an Image object that specifies the source image.

-param destRect [in, ref]

Type: const RectF

Reference to a rectangle that bounds the drawing area for the image.

-param srcx [in]

Type: REAL

Real number that specifies the x-coordinate of the upper-left corner of the portion of the source image to be drawn.

-param srcy [in]

Type: REAL

Real number that specifies the y-coordinate of the upper-left corner of the portion of the source image to be drawn.

-param srcwidth [in]

Type: REAL

Real number that specifies the width of the portion of the source image to be drawn.

-param srcheight [in]

Type: REAL

Real number that specifies the height of the portion of the source image to be drawn.

-param srcUnit [in]

Type: Unit

Element of the Unit enumeration that specifies the unit of measure for the image. The default value is UnitPixel.

-param imageAttributes [in]

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.

-param callback [in]

Type: DrawImageAbort

Callback method used to cancel the drawing in progress. The default value is NULL.

-param callbackData [in]

Type: VOID*

Pointer to additional data used by the method specified by the callback parameter. The default value is NULL.

-returns

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.

-remarks

The portion of the source image to be drawn is scaled to fit the rectangle.

Examples

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.

Illustration showing two graphics: a multicolored checkerboard pattern, then a two-toned enlargement from that pattern

-see-also

Drawing, Positioning, and Cloning Images

Graphics

Image

ImageAttributes

Loading and Displaying Bitmaps

Point

SetRemapTable

Unit