Share via


Graphics::D rawImage (Image*,constPoint*,INT,INT,INT,INT,Unit,constImageAttributes*,DrawImageAbort,VOID*) 方法 (gdiplusgraphics.h)

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

語法

Status DrawImage(
  [in] Image                 *image,
  [in] const Point           *destPoints,
  [in] INT                   count,
  [in] INT                   srcx,
  [in] INT                   srcy,
  [in] INT                   srcwidth,
  [in] INT                   srcheight,
  [in] Unit                  srcUnit,
  [in] const ImageAttributes *imageAttributes,
  [in] DrawImageAbort        callback,
  [in] VOID                  *callbackData
);

參數

[in] image

類型: 影像*

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

[in] destPoints

類型:const Point*

Point物件的陣列指標,該陣列會指定要在其中繪製影像之平行方塊中的區域。

[in] count

類型: INT

整數,指定 destPoints 陣列中的專案數目。

[in] srcx

類型: INT

實數,指定要繪製之來源影像部分左上角的 X 座標。

[in] srcy

類型: INT

實數,指定要繪製之來源影像部分左上角的 Y 座標。

[in] srcwidth

類型: INT

實數,指定要繪製之來源影像部分的寬度。

[in] srcheight

類型: INT

實數,指定要繪製之來源影像部分的高度。

[in] srcUnit

類型: 單位

Unit列舉的 元素,指定影像的測量單位。 預設值為 UnitPixel

[in] imageAttributes

類型: ImageAttributes*

ImageAttributes物件的指標,指定要繪製之影像的色彩和大小屬性。 預設值是 NULL

[in] callback

類型: DrawImageAbort

用來取消進行中繪圖的回呼方法。 預設值是 NULL

[in] callbackData

類型: VOID*

參數所指定方法所使用的其他資料的指標。 預設值是 NULL

傳回值

類型: 狀態

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

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

備註

count參數的值必須等於 3,才能指定平行投影的三個角落。 平行投影的第四個角落是使用第一個和第二個座標的向量和第一個和第三個座標來計算。 要繪製的來源影像部分會縮放以符合平行投影。

範例

下列範例會繪製原始來源影像,然後在指定的平行投影中繪製影像的一部分。

VOID Example_DrawImage2(HDC hdc)

{
   Graphics graphics(hdc);

   // Create an Image object.
   Image image(L"pattern.png");

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

   // Define the portion of the image to draw.
   int srcX = 70;
   int srcY = 20;
   int srcWidth = 100;
   int srcHeight = 100;

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

   Point* pdestPoints = destPoints;

   // Create an ImageAttributes object that specifies a recoloring from red to blue.
   ImageAttributes remapAttributes;
   ColorMap redToBlue;
   redToBlue.oldColor = Color(255, 255, 0, 0);
   redToBlue.newColor = Color(255, 0, 0, 255);
   remapAttributes.SetRemapTable(1, &redToBlue);

   // Draw the cropped image.
   graphics.DrawImage(
   &image,
   pdestPoints,
   3,
   srcX,
   srcY,
   srcWidth,
   srcHeight,
   UnitPixel,
   &remapAttributes,
   NULL,
   NULL);
}

下圖顯示上述程式碼的輸出。

顯示多色複選板模式的圖例,然後顯示該模式的放大、雙色子集,並切割成平行投影

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdiplusgraphics.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

繪製、定位和複製影像

圖形

映像

ImageAttributes

載入和顯示點陣圖

SetRemapTable