Share via


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

Graphics::D rawImage 方法會繪製影像。

語法

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

參數

[in] image

類型: 影像*

指定來源影像之 Image 物件的指標。

[in, ref] rect

類型: const RectF

系結影像繪圖區域的矩形參考。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其他其中一個專案。

備註

縮放影像來符合矩形。

範例

下列範例會繪製來源影像、系結重設大小影像的矩形,然後繪製重設大小的影像以符合矩形。

VOID Example_DrawImage10(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 RectF object that specifies the destination of the image.
   RectF 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)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

繪製、定位和複製影像

圖形

映像

載入和顯示點陣圖

RectF