Graphics::D rawImage(Image*,constRect&,INT,INT,INT,Unit,constImageAttributes*,DrawImageAbort,VOID*) メソッド (gdiplusgraphics.h)

Graphics::D rawImage メソッドはイメージを描画します。

構文

Status DrawImage(
  [in]      Image                 *image,
  [in, ref] const Rect &          destRect,
  [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, ref] destRect

型: const Rect

イメージの描画領域を囲む四角形への参照。

[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*

callback パラメーターで指定された メソッドで使用される追加データへのポインター。 既定値は NULL です。

戻り値

種類: 状態

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

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

注釈

描画するソース イメージの部分は、四角形に合わせて拡大縮小されます。

次の例では、元のソース イメージを描画し、指定した四角形にイメージの一部を描画します。

VOID Example_DrawImage5(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 a Rect object that specifies the destination of the image.
   Rect destRect(200, 10, image.GetWidth(), image.GetHeight());

   // 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 resized image.
   graphics.DrawImage(
   &image,
   destRect,
   srcX,
   srcY,
   srcWidth,
   srcHeight,
   UnitPixel,
   &remapAttributes,
   NULL,
   NULL);
}

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

2 つのグラフィックスを示す図:多色チェッカーボード パターン、そのパターンからの 2 トンの拡大

要件

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

こちらもご覧ください

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

グラフィックス

Image

ImageAttributes

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

Point

SetRemapTable

単位