Share via


Graphics::TransformPoints (CoordinateSpace,CoordinateSpace,Point*,INT) 方法 (gdiplusgraphics.h)

Graphics::TransformPoints 方法會將點陣列從一個座標空間轉換成另一個座標空間。 轉換是以這個 Graphics 物件的目前世界和頁面轉換為基礎。

語法

Status TransformPoints(
  [in]      CoordinateSpace destSpace,
  [in]      CoordinateSpace srcSpace,
  [in, out] Point           *pts,
  [in]      INT             count
);

參數

[in] destSpace

類型: CoordinateSpace

指定目的地座標空間之 CoordinateSpace 列舉的 元素。

[in] srcSpace

類型: CoordinateSpace

指定來源座標空間之 CoordinateSpace 列舉的專案。

[in, out] pts

類型: *

陣列的指標,在輸入時保留要轉換的點,並在輸出上保存轉換的點。

[in] count

類型: INT

整數,指定 pts 陣列中的項目數目。

傳回值

類型: 狀態

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

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

備註

世界轉換會將點從世界座標空間轉換成頁面座標空間。 頁面轉換會將點從頁面座標空間轉換為裝置座標空間。 如需座標空間的詳細資訊,請參閱 座標系統的類型

範例

下列範例會建立 Graphics 物件,並將其世界轉換設定為右移 40 單位和向下 30 個單位。 然後程式代碼會建立點陣列,並將該數位的位址傳遞至相同 Graphics 物件的 Graphics::TransformPoints 方法。 陣列中的點會由 Graphics 物件的世界轉換來轉換。 程序代碼會呼叫 Graphics::D rawLine 方法兩次:一次是連接轉換前的兩個點,一次是連接轉換后的兩點。

VOID Example_TransformPoints(HDC hdc)
{
   Graphics graphics(hdc);
   Pen pen(Color(255, 0, 0, 255));

   // Create an array of two Point objects.
   Point points[2] = {Point(0, 0), Point(100, 50)};

   // Draw a line that connects the two points.
   // No transformation has been performed yet.
   graphics.DrawLine(&pen, points[0], points[1]);

   // Set the world transformation of the Graphics object.
   graphics.TranslateTransform(40.0f, 30.0f);

   // Transform the points in the array from world to page coordinates.
   graphics.TransformPoints(
      CoordinateSpacePage, 
      CoordinateSpaceWorld, 
      points, 
      2);

   // It is the world transformation that takes points from world
   // space to page space. Because the world transformation is a
   // translation 40 to the right and 30 down, the
   // points in the array are now (40, 30) and (140, 80).

   // Draw a line that connects the transformed points.
   graphics.ResetTransform();
   graphics.DrawLine(&pen, points[0], points[1]);
}

規格需求

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

另請參閱

圖形

Graphics::GetTransform

Graphics::MultiplyTransform

Graphics::ResetTransform

Graphics::RotateTransform

Graphics::ScaleTransform

Graphics::SetTransform

Graphics::TranslateTransform

矩陣

MatrixOrder

轉換

座標系統類型