Graphics::D rawImage(Image*,constPointF*,INT,REAL,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 です。

戻り値

種類: 状態

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

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

注釈

count パラメーターの値は、平行四辺形の左上隅、右上隅、左下隅の座標を指定するために 3 と等しい必要があります。 右下隅の座標は、指定された 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);
}

次の図は、前のコードの出力を示しています。

多色チェッカーボード パターンを示す図、そのパターンの拡大された 2 色のサブセット(平行四辺形にせん断)

要件

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

こちらもご覧ください

画像の描画、配置、およびクローン作成

グラフィックス

Image

ImageAttributes

ビットマップの読み込みと表示

Point

SetRemapTable

単位