ImageAttributes::ClearBrushRemapTable 方法 (gdiplusimageattributes.h)

ImageAttributes::ClearBrushRemapTable方法會清除此ImageAttributes物件的筆刷色彩重新對應表。

Syntax

Status ClearBrushRemapTable();

傳回值

類型: 狀態

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

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

備註

ImageAttributes物件會維護五個調整類別的色彩和灰階設定:預設、點陣圖、筆刷、畫筆和文字。 例如,您可以針對預設類別指定一個色彩重新對應資料表、點陣圖類別的不同色彩重新對應表格,以及筆刷類別目錄的色彩重新對應表格。

預設色彩和灰階調整設定會套用至沒有自己調整設定的所有類別。 例如,如果您從未指定筆刷類別的任何調整設定,則預設設定會套用至筆刷類別。

一旦您指定特定類別的色彩或灰階調整設定,預設調整設定就不再套用至該類別。 例如,假設您指定將紅色轉換成綠色的預設重新對應表,並指定預設 gamma 值為 1.8。 如果您呼叫 ImageAttributes::SetBrushRemapTable,則預設的重新對應表會以紅色 (為綠色) ,而預設 gamma 值 (1.8) 不會套用至筆刷。 如果您稍後呼叫 ImageAttributes::ClearBrushRemapTable,筆刷類別將不會還原為預設的重新對應表;相反地,筆刷類別不會有重新對應表格。 同樣地,筆刷類別不會還原為預設 Gamma 值;相反地,筆刷類別不會有 gamma 值。

範例

下列範例會從 .emf 檔案建立 Image 物件。 程式碼也會建立 ImageAttributes 物件。 對 ImageAttributes::SetRemapTable 的呼叫會將 ImageAttributes 物件的預設色彩重新對應表格設定為將紅色轉換成藍色的資料表。 呼叫 ImageAttributes::SetBrushRemapTable 會將 ImageAttributes 物件的筆刷重新對應表格設定為將紅色轉換成綠色的資料表。

程式碼會呼叫 DrawImage 一次,以繪製沒有色彩調整的影像。 然後程式碼會再呼叫 DrawImage 三次,每次傳遞 Image 物件的位址和 ImageAttributes 物件的位址。 第二次在呼叫 ImageAttributes::SetRemapTable) 之後繪製影像 (,所有紅色都會轉換成藍色。 第三次在呼叫 ImageAttributes::SetBrushRemapTable) 之後 (繪製影像時,所有以筆刷繪製的紅色都會轉換成綠色,而其餘的紅色則會轉換成藍色。 第四次在呼叫 ImageAttributes::ClearBrushRemap) Table 之後繪製影像 (,所有以筆刷繪製的紅色都會保持不變,而其餘的紅色則會轉換成藍色。


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

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

   ColorMap defaultMap;
   defaultMap.oldColor = Color(255, 255, 0, 0);   // red converted to blue
   defaultMap.newColor = Color(255, 0, 0, 255);

   ColorMap brushMap;
   brushMap.oldColor = Color(255, 255, 0, 0);     // red converted to green
   brushMap.newColor = Color(255, 0, 255, 0);

   // Set the default color-remap table.
   imAtt.SetRemapTable(1, &defaultMap, ColorAdjustTypeDefault);

   // Draw the image (metafile) using no color adjustment.
   graphics.DrawImage(
      &image,
      Rect(10, 10, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),          // source rect
      UnitPixel);

   // Draw the image (metafile) using default color adjustment.
   // All red is converted to blue.
   graphics.DrawImage(
      &image,
      Rect(10, 90, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),          // source rect
      UnitPixel,
      &imAtt);

   // Set the brush remap table.
   imAtt.SetBrushRemapTable(1, &brushMap);

   // Draw the image (metafile) using default and brush adjustment.
   // Red painted with a brush is converted to green.
   // All other red is converted to blue (default).
   graphics.DrawImage(
      &image,
      Rect(10, 170, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),           // source rect
      UnitPixel,
      &imAtt);

   // Clear the brush remap table.
   imAtt.ClearBrushRemapTable();

   // Draw the image (metafile) using only default color adjustment.
   // Red painted with a brush gets no color adjustment.
   // All other red is converted to blue (default).
   graphics.DrawImage(
      &image,
      Rect(10, 250, image.GetWidth(), image.GetHeight()),  // dest rect
      0, 0, image.GetWidth(), image.GetHeight(),           // source rect
      UnitPixel,
      &imAtt);  
}
				

上述程式碼以及特定的檔案 Testmetafile4.emf 會產生下列輸出。 左側資料行中的省略號是使用畫筆繪製,而右邊資料行中的省略號則填入筆刷。 請注意,預設的重新對應表格會套用至使用畫筆繪製的省略號。 套用至筆刷填滿橢圓形的重新對應表會根據 ImageAttributes::SetBrushRemapTableImageAttributes::ClearBrushRemapTable 呼叫而有所不同。

顯示四個空白省略號的圖例;第一個是紅色和其餘藍色,然後四個填滿的橢圓形:紅色、藍色、綠色和紅色

需求

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

另請參閱

點陣圖

Color

ColorAdjustType

ColorMap

映像

ImageAttributes

ImageAttributes::ClearRemapTable

ImageAttributes::SetBrushRemapTable

ImageAttributes::SetRemapTable

中繼檔

重新著色