Поделиться через


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

Applies to: desktop apps only

The Graphics::DrawImage method draws an image.

Syntax

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

Parameters

  • image [in]
    Type: Image*

    Pointer to an Image object that specifies the source image.

  • destPoints [in]
    Type: const Point*

    Pointer to an array of Point 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 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

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