Bitmap::ApplyEffect (Bitmap**,INT,Effect*,RECT*,RECT*,Bitmap**) 方法 (gdiplusheaders.h)

Bitmap::ApplyEffect方法會將指定的效果套用至現有的Bitmap物件,以建立新的Bitmap物件。

語法

Status ApplyEffect(
  [in]  Bitmap **inputs,
  [in]  INT    numInputs,
  [in]  Effect *effect,
  [in]  RECT   *ROI,
  [out] RECT   *outputRect,
  [out] Bitmap **output
);

參數

[in] inputs

類型: 點陣圖**

套用效果之 Bitmap 物件的指標位址。

[in] numInputs

類型: INT

指定輸入點陣圖數目的整數。 此參數必須設定為 1。

[in] effect

類型: 效果*

Effect類別子系之實例的指標。 例如, Blur 物件) 指定套用的效果,例如子代 (。

[in] ROI

類型: RECT*

RECT 結構的指標,指定所使用的輸入點陣圖部分。

[out] outputRect

類型: RECT*

RECT 結構的指標,該結構會接收所使用的輸入點陣圖部分。 如果 ROI 指定的矩形完全位於輸入點陣圖內, 則 outputRect 中傳回的矩形與 ROI相同。 如果 ROI 所指定的矩形部分位於輸入點陣圖之外, 則 outputRect 中傳回的矩形是位於輸入點陣圖內的 ROI 部分。 如果您不想接收輸出矩形,請傳遞 Null

[out] output

類型: 點陣圖**

接收新 Bitmap 物件指標之變數的位址。

傳回值

類型: 狀態

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

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

備註

Bitmap::ApplyEffect 會傳回新 Bitmap 物件的指標。 當您完成使用該 Bitmap 物件時,請呼叫 delete 以釋放它佔用的記憶體。

範例

下列範例會建立兩個 Bitmap 物件: inputBitmapoutputBitmap。 首先, inputBitmap 是從 BMP 檔案建構的。 然後,將 inputBitmap的位址傳遞至Bitmap::ApplyEffect方法,即可建立outputBitmapBitmap::ApplyEffect會採用rectOfInterest所指定的inputBitmap部分,並增加briCon所指定之 BrightnessContrast物件的對比。

VOID Example_BrightnessContrastApplyEffect2(HDC hdc)
{
   Graphics graphics(hdc);
   Bitmap* inputBitmap = new Bitmap(L"Picture.bmp");
   Bitmap* outputBitmap = NULL;  
   RECT rectOfInterest = {10, 12, 100, 80};
  
   BrightnessContrastParams briConParams;
   briConParams.brightnessLevel = 0;
   briConParams.contrastLevel = 25;
   BrightnessContrast briCon;
   briCon.SetParameters(&briConParams);

   // Draw the original image.
   graphics.DrawImage(inputBitmap, 20, 20);

   // Apply the change in contrast.
   Bitmap::ApplyEffect(
      &inputBitmap, 1, &briCon, &rectOfInterest, NULL, &outputBitmap);

   // Draw the new image.
   graphics.DrawImage(outputBitmap, 200, 20);

   delete inputBitmap;
   delete outputBitmap;
}

需求

   
最低支援的用戶端 Windows Vista [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 [僅限傳統型應用程式]
目標平台 Windows
標頭 gdiplusheaders.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

點陣圖

Bitmap::ApplyEffect 方法