ImageAttributes::SetOutputChannel 方法 (gdiplusimageattributes.h)

ImageAttributes::SetOutputChannel方法會設定指定類別的 CMYK 輸出通道。

語法

Status SetOutputChannel(
  [in]           ColorChannelFlags channelFlags,
  [in, optional] ColorAdjustType   type
);

參數

[in] channelFlags

類型: ColorChannelFlags

指定輸出通道的 ColorChannelFlags 列舉專案。

[in, optional] type

類型: ColorAdjustType

ColorAdjustType列舉的元素,指定已設定輸出通道的類別。 預設值為 ColorAdjustTypeDefault

傳回值

類型: 狀態

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

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

備註

您可以使用 ImageAttributes::SetOutputChannel 方法,將影像轉換成青色-magenta-yellow-black (CMYK) 色彩空間,並檢查其中一個 CMYK 色彩通道的強度。 例如,假設您建立 ImageAttributes 物件,並將其點陣圖輸出通道設定為 ColorChannelFlagsC。 如果您將該 ImageAttributes 物件的位址傳遞至 DrawImage 方法,則會計算每個圖元的青色元件,而轉譯影像中的每個圖元都是灰色的陰影,表示其青色色板的強度。 同樣地,您可以轉譯影像,指出放大鏡、黃色和黑色通道的濃度。

ImageAttributes物件會維護五個調整類別的色彩和灰階設定:預設、點陣圖、筆刷、手寫筆和文字。 例如,您可以指定預設類別的輸出通道,以及點陣圖類別的不同輸出通道。

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

一旦您指定特定類別的色彩或灰階調整設定,預設調整設定就不再套用至該類別。 例如,假設您指定預設類別的調整設定集合。 如果您藉由將 ColorAdjustTypeBitmap 傳遞至 ImageAttributes::SetOutputChannel 方法來設定點陣圖類別的輸出通道,則不會將任何預設調整設定套用至點陣圖。

範例

下列範例會建立 Image 物件,並呼叫 DrawImage 方法來繪製影像。 然後程式碼會建立 ImageAttributes 物件,並將其點陣圖輸出通道設定為青色 (ColorChannelFlagsC) 。 程式碼會再次呼叫DrawImage,傳遞 Image 物件的位址和ImageAttributes物件的位址。 系統會計算每個圖元的青色板,而轉譯的影像會將青色色板的濃度顯示為灰色的陰影。 程式碼會再呼叫 DrawImage 三次,以顯示 magenta、黃色和黑色通道的濃度。


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

   Image image(L"Mosaic2.bmp");

   // Draw the image unaltered.
   graphics.DrawImage(&image, 10, 10, width, height);

   UINT width = image.GetWidth();
   UINT height = image.GetHeight();

   ImageAttributes imAtt;

   // Draw the image, showing the intensity of the cyan channel.
   imAtt.SetOutputChannel(ColorChannelFlagsC, ColorAdjustTypeBitmap);
   graphics.DrawImage(
      &image,
      Rect(110, 10, width, height),  // dest rect
      0, 0, width, height,           // source rect
      UnitPixel,
      &imAtt);

   // Draw the image, showing the intensity of the magenta channel.
   imAtt.SetOutputChannel(ColorChannelFlagsM, ColorAdjustTypeBitmap);
   graphics.DrawImage(
      &image,
      Rect(210, 10, width, height),  // dest rect
      0, 0, width, height,           // source rect
      UnitPixel,
      &imAtt);

   // Draw the image, showing the intensity of the yellow channel.
   imAtt.SetOutputChannel(ColorChannelFlagsY, ColorAdjustTypeBitmap);
   graphics.DrawImage(
      &image,
      Rect(10, 110, width, height),  // dest rect
      0, 0, width, height,           // source rect
      UnitPixel,
      &imAtt);

   // Draw the image, showing the intensity of the black channel.
   imAtt.SetOutputChannel(ColorChannelFlagsK, ColorAdjustTypeBitmap);
   graphics.DrawImage(
      &image,
      Rect(110, 110, width, height),  // dest rect
      0, 0, width, height,            // source rect
      UnitPixel,
      &imAtt); 
}
				

下圖顯示上述程式碼的輸出。

顯示五個影像版本的圖例:首先以色彩顯示,然後在四種不同的灰階模式中

需求

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

另請參閱

ColorAdjustType

ColorChannelFlags

ImageAttributes

ImageAttributes::ClearOutputChannel

ImageAttributes::ClearOutputChannelColorProfile

ImageAttributes::SetOutputChannelColorProfile