Share via


Graphics.DrawImage(Image*, const PointF*, INT) method

Applies to: desktop apps only

The Graphics::DrawImage method draws an image.

Syntax

Status DrawImage(
  [in]  Image *image,
  [in]  const PointF *destPoints,
  [in]  INT count
);

Parameters

  • image [in]
    Type: Image*

    Pointer to an Image object that specifies the source image.

  • destPoints [in]
    Type: const PointF*

    Pointer to an array of PointF objects that specify the area, in a parallelogram, in which to draw the image.

  • count [in]
    Type: INT

    Integer that specifies the number of elements in the destPoints array.

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.

Remarks

The value of the count parameter must equal 3 to specify the coordinates of the upper-left corner, upper-right corner, and lower-left corner of the parallelogram. The coordinate of the lower-right corner is calculated using the three given coordinates, the width, and the height of the image. The image is scaled to fit the parallelogram.

Examples

The following example draws an image.

VOID Example_DrawImage3(HDC hdc)

{
   Graphics graphics(hdc);

   // Create an Image object.
   Image image(L"climber.jpg");

   // Create an array of PointF objects that specify the destination of the image.
   PointF destPoints[3] = {
   PointF(30.0f, 30.0f),
   PointF(250.0f, 50.0f),
   PointF(175.0f, 120.0f)};

   PointF* pdestPoints = destPoints;

   // Draw the image.
   graphics.DrawImage(&image, pdestPoints, 3);
}

The following illustration shows the output of the preceding code.

Illustration showing a previously-rectangular image that has been sheared to a parallelogram

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

Graphics

Image

Point

Loading and Displaying Bitmaps

Drawing, Positioning, and Cloning Images

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012