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

Bitmap::ApplyEffect 方法通过应用指定的效果来更改此 Bitmap 对象。

语法

Status ApplyEffect(
  Effect *effect,
  RECT   *ROI
);

参数

effect

指向 Effect 类的子代实例的指针。 例如,后代 (Blur 对象) 指定应用的效果。

ROI

指向 RECT 结构的指针,该结构指定应用效果的输入位图部分。 传递 NULL 以指定效果应用于整个输入位图。

返回值

类型: 状态

如果方法成功,则返回 Ok,这是 Status 枚举的元素。

如果 方法失败,它将返回 Status 枚举的其他元素之一。

注解

示例

以下示例绘制图像两次:一次不更改,一次在部分图像的亮度增加后绘制。

VOID Example_BrightnessContrastApplyEffect1(HDC hdc)
{
   Graphics graphics(hdc);
   Bitmap myBitmap(L"Picture.bmp");
   UINT srcWidth = myBitmap.GetWidth();
   UINT srcHeight = myBitmap.GetHeight();

   BrightnessContrastParams briConParams;
   briConParams.brightnessLevel = 50;
   briConParams.contrastLevel = 0;
   BrightnessContrast briCon;
   briCon.SetParameters(&briConParams);
   RECT rectOfInterest = {20, 15, 80, 50};

   // Draw the original image.
   graphics.DrawImage(&myBitmap, 20, 20, srcWidth, srcHeight);

   // Increase the brightness in a portion of the image.
   myBitmap.ApplyEffect(&briCon, &rectOfInterest);

   // Draw the image again.
   graphics.DrawImage(&myBitmap, 200, 20, srcWidth, srcHeight);
}

要求

要求
Header gdiplusheaders.h

另请参阅

Bitmap