ImageAttributes::ClearNoOp method (gdiplusimageattributes.h)

The ImageAttributes::ClearNoOp method clears the NoOp setting for a specified category.

Syntax

Status ClearNoOp(
  [in, optional] ColorAdjustType type
);

Parameters

[in, optional] type

Type: ColorAdjustType

Element of the ColorAdjustType enumeration that specifies the category for which the NoOp setting is cleared. The default value is ColorAdjustTypeDefault.

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

You can disable color adjustment for a certain object type by calling the ImageAttributes::SetNoOp method. Later, you can reinstate color adjustment for that object type by calling the ImageAttributes::ClearNoOp method. For example, the following statement disables color adjustment for brushes:

myImageAttributes.SetNoOp(ColorAdjustTypeBrush);

The following statement reinstates the brush color adjustment that was in place before the call to ImageAttributes::SetNoOp:

myImageAttributes.ClearNoOp(ColorAdjustTypeBrush);

Examples

The following example creates an Image object from a .emf file. The code also creates an ImageAttributes object. The ImageAttributes::SetColorMatrix call sets the brush color-adjustment matrix of that ImageAttributes object to a matrix that converts red to green.

The code calls DrawImage three times, each time passing the address of the Image object and the address of the ImageAttributes object. When the image is drawn the first time, all the red painted by brushes is converted to green. (The red drawn by pens is not changed.) Before the image is drawn the second time, the code calls the ImageAttributes::SetNoOp method of the ImageAttributes object. So when the image is drawn the second time, no color adjustment is applied to brushes. Before the image is drawn the third time, the code calls the ImageAttributes::ClearNoOp method, which reinstates the brush color-adjustment settings. So when the image is drawn the third time, all the red painted by brushes is converted to green.


VOID Example_SetClearNoOp(HDC hdc)
{
   Graphics graphics(hdc);

   Image image(L"TestMetafile4.emf");
   ImageAttributes imAtt;

    ColorMatrix brushMatrix = {     // red converted to green
      0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
      0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
      0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
      0.0f, 0.0f, 0.0f, 1.0f, 0.0f,
      0.0f, 0.0f, 0.0f, 0.0f, 1.0f};

   imAtt.SetColorMatrix(
      &brushMatrix, 
      ColorMatrixFlagsDefault, 
      ColorAdjustTypeBrush);

   // Draw the image (metafile) using brush color adjustment.
   // Items filled with a brush change from red to green.
   graphics.DrawImage(
      &image,
      Rect(0, 0, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),        // source rect
      UnitPixel,
      &imAtt);

   // Temporarily disable brush color adjustment.
   imAtt.SetNoOp(ColorAdjustTypeBrush);

   // Draw the image (metafile) without brush color adjustment.
   // There is no change from red to green.
   graphics.DrawImage(
      &image,
      Rect(0, 80, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),          // source rect
      UnitPixel,
      &imAtt);

   // Reinstate brush color adjustment.
   imAtt.ClearNoOp(ColorAdjustTypeBrush);

   // Draw the image (metafile) using brush color adjustment.
   // Items filled with a brush change from red to green.
   graphics.DrawImage(
      &image,
      Rect(0, 160, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),          // source rect
      UnitPixel,
      &imAtt);
}
				

Requirements

Requirement Value
Minimum supported client Windows XP, Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header gdiplusimageattributes.h (include Gdiplus.h)
Library Gdiplus.lib
DLL Gdiplus.dll

See also

Bitmap

ColorAdjustType

Image

ImageAttributes

ImageAttributes::Reset

ImageAttributes::SetNoOp

ImageAttributes::SetToIdentity

Metafile

Recoloring