Graphics::D rawImage (Image*,constRect&) 方法 (gdiplusgraphics.h)

Graphics::D rawImage 方法绘制图像。

语法

Status DrawImage(
  [in]      Image        *image,
  [in, ref] const Rect & rect
);

参数

[in] image

类型: 图像*

指向指定源 图像的 Image 对象的指针。

[in, ref] rect

类型: const Rect

对边框的引用,该矩形绑定图像的绘图区域。

返回值

类型: 状态

如果方法成功,则返回 Ok,这是 Status 枚举的元素。

如果 方法失败,它将返回 Status 枚举的其他元素之一。

注解

将图像进行缩放以适合该矩形。

示例

以下示例绘制源图像,即绑定调整大小的图像的矩形,然后绘制调整大小的图像以适应矩形。

VOID Example_DrawImage9(HDC hdc)

{
   Graphics graphics(hdc);

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

   // Create a Pen object.
   Pen pen (Color(255, 255, 0, 0), 2);

   // Draw the original source image.
   graphics.DrawImage(&image, 10, 10);

   // Create a Rect object that specifies the destination of the image.
   Rect destRect(200, 50, 150, 75);

   // Draw the rectangle that bounds the image.
   graphics.DrawRectangle(&pen, destRect);

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

下图显示了上述代码的输出。

显示同一映像的两个版本的插图;第二个略窄于第一个,短得多,并用红色边框

要求

   
最低受支持的客户端 Windows XP、Windows 2000 Professional [仅限桌面应用]
最低受支持的服务器 Windows 2000 Server [仅限桌面应用]
目标平台 Windows
标头 gdiplusgraphics.h (包括 Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

另请参阅

绘制、定位和复制图像

显卡

图像

加载和显示位图

Rect