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

The Bitmap::ApplyEffect method creates a new Bitmap object by applying a specified effect to an existing Bitmap object.

Syntax

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

Parameters

[in] inputs

Type: Bitmap**

Address of a pointer to a Bitmap object to which the effect is applied.

[in] numInputs

Type: INT

Integer that specifies the number of input bitmaps. This parameter must be set to 1.

[in] effect

Type: Effect*

Pointer to an instance of a descendant of the Effect class. The descendant (for example, a Blur object) specifies the effect that is applied.

[in] ROI

Type: RECT*

Pointer to a RECT structure that specifies the portion of the input bitmap that is used.

[out] outputRect

Type: RECT*

Pointer to a RECT structure that receives the portion of the input bitmap that was used. If the rectangle specified by ROI lies entirely within the input bitmap, the rectangle returned in outputRect is the same as ROI. If part of rectangle specified by ROI lies outside the input bitmap, then the rectangle returned in outputRect is the portion of ROI that lies within the input bitmap. Pass NULL if you do not want to receive the output rectangle.

[out] output

Type: Bitmap**

Address of a variable that receives a pointer to the new Bitmap object.

Return value

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Remarks

Bitmap::ApplyEffect returns a pointer to a new Bitmap object. When you have finished using that Bitmap object, call delete to free the memory that it occupies.

Examples

The following example creates two Bitmap objects: inputBitmap and outputBitmap. First, inputBitmap is constructed from a BMP file. Then outputBitmap is created by passing the address of inputBitmap to the Bitmap::ApplyEffect method. Bitmap::ApplyEffect takes the portion of inputBitmap specified by rectOfInterest and increases the contrast as specified by briCon, a BrightnessContrast object.

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;
}

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header gdiplusheaders.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Bitmap

Bitmap::ApplyEffect Methods