GraphicsPath::Warp メソッド (gdipluspath.h)

GraphicsPath::Warp メソッドは、このパスに反り変換を適用します。 GraphicsPath::Warp メソッドは、パスをフラット化 (直線のシーケンスに変換) します。

構文

Status Warp(
  [in]      const PointF  *destPoints,
  [in]      INT           count,
  [in, ref] const RectF & srcRect,
  [in]      const Matrix  *matrix,
  [in]      WarpMode      warpMode,
  [in]      REAL          flatness
);

パラメーター

[in] destPoints

型: const PointF*

srcRect パラメーターと共に、反り変換を定義するポイントの配列へのポインター。

[in] count

型: INT

destPoints 配列内のポイント数を指定する整数。 このパラメーターの値は 3 または 4 である必要があります。

[in, ref] srcRect

型: const RectF

destPoints パラメーターと共に、反り変換を定義する四角形への参照。

[in] matrix

型: const Matrix*

省略可能。 反りと共に適用する変換を表す Matrix オブジェクトへのポインター。 このパラメーターが NULL の場合、変換は適用されません。 既定値は NULL です。

[in] warpMode

種類: WarpMode

省略可能。 適用する反りの種類を指定する WarpMode 列挙体の要素。 既定値は WarpModePerspective です。

[in] flatness

種類: REAL

省略可能。 元のパスの近似に使用される線分の数に影響する実数。 値を小さくすると、多数の線分が使用され、大きな値では使用される線分が少なくなります。 既定値は FlatnessDefault です。これは Gdiplusenums.h で定義されている定数です。

戻り値

種類: 状態

メソッドが成功した場合は、 Status 列挙体の要素である Ok を返します。

メソッドが失敗した場合は、 Status 列挙体の他の要素のいずれかを返します。

注釈

GraphicsPath オブジェクトは、線と曲線を表すデータ ポイントのコレクションを格納します。 GraphicsPath::Warp メソッドは、これらのデータ ポイントを変換して、線のみを表します。 flatness パラメーターは、格納されている行の数に影響します。 曲線を表す元のデータ ポイントは失われます。

count パラメーターの値が 4 の場合、次の表に示すように反り変換が定義されます。

ソース ポイント 対象の点
srcRect の左上隅 destPoints[0]
srcRect の右上隅 destPoints[1]
srcRect の左下隅 destPoints[2]
srcRect の右下隅 destPoints[3]
 

ソース四角形と 4 つの変換先ポイントで指定された変換は、必ずしも平行四辺形ではない任意の四角形に四角形をマッピングできます。

count パラメーターの値が 3 の場合、次の表に示すように反り変換が定義されます。

ソース ポイント 対象の点
srcRect の左上隅 destPoints[0]
srcRect の右上隅 destPoints[1]
srcRect の左下隅 destPoints[2]
 

変換元の四角形と 3 つの変換先ポイントで指定された変換は、四角形を平行四辺形にマップします。

次の例では 、GraphicsPath オブジェクトを作成し、閉じた図形をパスに追加します。 このコードでは、ソース四角形と 4 つの変換先ポイントの配列を指定して、反り変換を定義します。 ソースの四角形と変換先のポイントは 、Warp メソッドに渡されます。 このコードでは、パスを 2 回描画します。パスは、反る前に 1 回、反った後に 1 回描画されます。


VOID WarpExample(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a path.
   PointF points[] ={
      PointF(20.0f, 60.0f),
      PointF(30.0f, 90.0f),
      PointF(15.0f, 110.0f),
      PointF(15.0f, 145.0f),
      PointF(55.0f, 145.0f),
      PointF(55.0f, 110.0f),
      PointF(40.0f, 90.0f),
      PointF(50.0f, 60.0f)};

   GraphicsPath path;
   path.AddLines(points, 8);
   path.CloseFigure();

   // Draw the path before applying a warp transformation.
   Pen bluePen(Color(255, 0, 0, 255));
   graphics.DrawPath(&bluePen, &path);

   // Define a warp transformation, and warp the path.
   RectF srcRect(10.0f, 50.0f, 50.0f, 100.0f);

   PointF destPts[] = {
      PointF(220.0f, 10.0f),
      PointF(280.0f, 10.0f),
      PointF(100.0f, 150.0f),
      PointF(400.0f, 150.0f)};

   path.Warp(destPts, 4, srcRect);

   // Draw the warped path.
   graphics.DrawPath(&bluePen, &path);

   // Draw the source rectangle and the destination polygon.
   Pen blackPen(Color(255, 0, 0, 0));
   graphics.DrawRectangle(&blackPen, srcRect);
   graphics.DrawLine(&blackPen, destPts[0], destPts[1]);
   graphics.DrawLine(&blackPen, destPts[0], destPts[2]);
   graphics.DrawLine(&blackPen, destPts[1], destPts[3]);
   graphics.DrawLine(&blackPen, destPts[2], destPts[3]);
}

要件

要件
サポートされている最小のクライアント Windows XP、Windows 2000 Professional [デスクトップ アプリのみ]
サポートされている最小のサーバー Windows 2000 Server [デスクトップ アプリのみ]
対象プラットフォーム Windows
ヘッダー gdipluspath.h (Gdiplus.h を含む)
Library Gdiplus.lib
[DLL] Gdiplus.dll

こちらもご覧ください

領域でのクリッピング

パスの作成および描画

パス グラデーションの作成

フラット化パス

Graphicspath

GraphicsPath::Flatten

GraphicsPath::Outline

GraphicsPath::Widen

マトリックス

パス

WarpMode