Graphics::D rawImage (Image*,constPointF*,INT,REAL,REAL,Unit,constImageAttributes*,DrawImageAbort,VOID*) 方法 (gdiplusgraphics.h)
Graphics::D rawImage 方法會繪製影像。
語法
Status DrawImage(
[in] Image *image,
[in] const PointF *destPoints,
[in] INT count,
[in] REAL srcx,
[in] REAL srcy,
[in] REAL srcwidth,
[in] REAL srcheight,
[in] Unit srcUnit,
[in] const ImageAttributes *imageAttributes,
[in] DrawImageAbort callback,
[in] VOID *callbackData
);
參數
[in] image
類型: 影像*
指定來源影像之 Image 物件的指標。
[in] destPoints
類型: const PointF*
PointF 物件的陣列指標,指定繪製影像之平行方塊中的區域。
[in] count
類型: INT
整數,指定 destPoints 陣列中的項目數目。
[in] srcx
類型: REAL
實際數位,指定要繪製之來源影像部分左上角的 X 座標。
[in] srcy
類型: REAL
實際數位,指定要繪製之來源影像部分左上角的 Y 座標。
[in] srcwidth
類型: REAL
實際數位,指定要繪製之來源影像部分的寬度。
[in] srcheight
類型: REAL
實際數位,指定要繪製之來源影像部分的高度。
[in] srcUnit
類型: 單位
Unit 列舉的 元素,指定影像的測量單位。 預設值為 UnitPixel。
[in] imageAttributes
類型: ImageAttributes*
ImageAttributes 物件的指標,指定要繪製之影像的色彩和大小屬性。 預設值是 NULL。
[in] callback
類型: DrawImageAbort
用來取消進行中繪圖的回呼方法。 預設值是 NULL。
[in] callbackData
類型: VOID*
回 呼 參數所指定方法所使用之其他數據的指標。 預設值是 NULL。
傳回值
類型: 狀態
如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。
如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。
備註
count 參數的值必須等於 3,才能指定平行投影左上角、右上角和左下角的座標。 右下角的座標是使用三個指定的座標、寬度和影像的高度來計算。 要繪製的來源影像部分會縮放以符合平行投影。
範例
下列範例會繪製原始來源影像,然後在指定的平行投影中繪製影像的一部分。
VOID Example_DrawImage4(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.
REAL srcX = 70.0f;
REAL srcY = 20.0f;
REAL srcWidth = 100.0f;
REAL srcHeight = 100.0f;
// Create an array of Point objects that specify the destination of the cropped image.
PointF destPoints[3] = {
PointF(230.0f, 30.0f),
PointF(350.0f, 50.0f),
PointF(275.0f, 120.0f)};
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 |
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應