Graphics::DrawImage(Image*,constPoint*,INT) method (gdiplusgraphics.h)

The Graphics::DrawImage method draws an image.

Syntax

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

Parameters

[in] image

Type: Image*

Pointer to an Image object that specifies the source image.

[in] destPoints

Type: const Point*

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

[in] count

Type: INT

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

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns InvalidParameter.

Remarks

The value of the count parameter must equal 3 to specify the three corners of the parallelogram. The fourth corner of the parallelogram is calculated using the vectors of the first and second coordinates and the first and third coordinates. The image is scaled to fit the parallelogram.

Examples

The following example draws an image.

VOID Example_DrawImage(HDC hdc)

{

   Graphics graphics(hdc);

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

   // Create an array of Point objects that specify the destination of the image.
   Point destPoints[3] = {
   Point(30, 30),
   Point(250, 50),
   Point(175, 120)};

   Point* 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 is now sheared to a parallelogram

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusgraphics.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Drawing, Positioning, and Cloning Images

Graphics

Image

Loading and Displaying Bitmaps

Point