ImageAttributes::ClearNoOp 方法 (gdiplusimageattributes.h)

ImageAttributes::ClearNoOp 方法會清除指定類別的 NoOp 設定。

語法

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

參數

[in, optional] type

類型: ColorAdjustType

ColorAdjustType 列舉的元素,指定清除 NoOp 設定的類別。 預設值為 ColorAdjustTypeDefault

傳回值

類型: 狀態

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

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

備註

您可以呼叫 ImageAttributes::SetNoOp 方法,以停用特定物件類型的色彩調整。 稍後,您可以呼叫 ImageAttributes::ClearNoOp 方法,以恢復該物件類型的色彩調整。 例如,下列語句會停用筆刷的色彩調整:

myImageAttributes.SetNoOp(ColorAdjustTypeBrush);

下列語句會恢復在呼叫 ImageAttributes::SetNoOp 之前就地的筆刷色彩調整:

myImageAttributes.ClearNoOp(ColorAdjustTypeBrush);

範例

下列範例會從.emf檔案建立 Image 物件。 程序代碼也會建立 ImageAttributes 物件。 ImageAttributes::SetColorMatrix 呼叫會將該 ImageAttributes 物件的筆刷色彩調整矩陣設定為將紅色轉換為綠色的矩陣。

程序代碼會呼叫 DrawImage 三次,每次傳遞 Image 物件的位址和 ImageAttributes 物件的位址。 第一次繪製影像時,筆刷繪製的所有紅色都會轉換成綠色。 (畫筆繪製的紅色不會變更。) 第二次繪製影像之前,程式代碼會呼叫 ImageAttributes::SetNoOp 物件的 ImageAttributes::SetNoOp 方法。 因此,第二次繪製影像時,不會將色彩調整套用至筆刷。 第三次繪製影像之前,程式代碼會呼叫 ImageAttributes::ClearNoOp 方法,以恢復筆刷色彩調整設定。 因此,第三次繪製影像時,筆刷繪製的所有紅色都會轉換成綠色。


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

規格需求

需求
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限桌面應用程式]
最低支援的伺服器 Windows 2000 Server [僅限桌面應用程式]
目標平台 Windows
標頭 gdiplusimageattributes.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

點陣圖

ColorAdjustType

映像

ImageAttributes

ImageAttributes::Reset

ImageAttributes::SetNoOp

ImageAttributes::SetToIdentity

元檔

重新著色