ImageAttributes::SetOutputChannelColorProfile 方法 (gdiplusimageattributes.h)

ImageAttributes::SetOutputChannelColorProfile 方法會設定指定類別的輸出通道色彩配置檔。

語法

Status SetOutputChannelColorProfile(
  [in]           const WCHAR     *colorProfileFilename,
  [in, optional] ColorAdjustType type
);

參數

[in] colorProfileFilename

類型: const WCHAR*

色彩配置檔案的路徑名稱。 如果色彩配置檔位於 %SystemRoot%\System32\Spool\Drivers\Color 目錄中,則此參數可以是檔名。 否則,這個參數就必須是完整路徑名稱。

[in, optional] type

類型: ColorAdjustType

ColorAdjustType 列舉的 元素,指定設定輸出通道色彩配置檔檔案的類別。 預設值為 ColorAdjustTypeDefault

傳回值

類型: 狀態

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

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

備註

您可以使用 ImageAttributes::SetOutputChannelImageAttributes::SetOutputChannelColorProfile 方法,將影像轉換成青色-magenta-yellow-black (CMYK) 色彩空間,並檢查其中一個 CMYK 色彩通道的強度。 例如,假設您撰寫的程式代碼會執行下列步驟:

  1. 建立 Image 物件。
  2. 建立 ImageAttributes 物件。
  3. ColorChannelFlagsC 傳遞給 ImageAttributes 物件的 ImageAttributes::SetOutputChannel 方法。
  4. 將色彩配置檔案的路徑名稱傳遞至 ImageAttributes 物件的 ImageAttributes::SetOutputChannelColorProfile 方法。
  5. ImageImageAttributes 物件的地址傳遞至 DrawImage 方法。
Windows GDI+ 會使用色彩配置檔檔案來計算影像中每個像素的青色元件,而轉譯影像中的每個像素都會是灰色的陰影,表示其青色色板的強度。

ImageAttributes 對象會維護五個調整類別的色彩和灰階設定:預設、點陣圖、筆刷、畫筆和文字。 例如,您可以指定預設類別的輸出通道色彩配置檔檔案,併為位陣圖類別指定不同的輸出通道色彩配置檔。

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

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

範例

下列範例會建立 Image 物件,並呼叫 DrawImage 方法來繪製影像。 然後程式代碼會建立 ImageAttributes 物件,並呼叫其 ImageAttributes::SetOutputChannelColorProfile 方法來指定位圖類別的配置檔。 對 ImageAttributes::SetOutputChannel 的呼叫會將點陣圖類別 (的輸出通道) 設為青色。 程序代碼會第二次呼叫 DrawImage ,傳遞 Image 物件的位址和 ImageAttributes 物件的位址。 系統會計算每個圖元的青色色板,而轉譯的影像會將青色色板的強度顯示為灰色的陰影。 程序代碼會再呼叫 DrawImage 三次,以顯示紅色、黃色和黑色通道的強度。


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

   Image image(L"Mosaic2.bmp");
   ImageAttributes imAtt;
   UINT width = image.GetWidth();
   UINT height = image.GetHeight();

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

   imAtt.SetOutputChannelColorProfile(
      L"TEKPH600.ICM", ColorAdjustTypeBitmap);

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

上述程序代碼以及 Mosaic2.bmp 和 Tekph600.icm 的檔案會產生下列輸出。

顯示一個影像四個版本的圖例:第一個以色彩顯示,然後以三種不同的灰階模式顯示

規格需求

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

另請參閱

ColorAdjustType

ColorChannelFlags

ImageAttributes

ImageAttributes::ClearOutputChannel

ImageAttributes::ClearOutputChannelColorProfile

ImageAttributes::SetOutputChannel