ImageAttributes.SetOutputChannel 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
設定 CMYK(青-洋紅-黃-黑)輸出通道。
多載
| 名稱 | Description |
|---|---|
| SetOutputChannel(ColorChannelFlag) |
預設類別的 CMYK(青-品紅-黃-黑)輸出通道。 |
| SetOutputChannel(ColorChannelFlag, ColorAdjustType) |
設定指定類別的CMYK(青-洋紅-黃-黑)輸出通道。 |
SetOutputChannel(ColorChannelFlag)
預設類別的 CMYK(青-品紅-黃-黑)輸出通道。
public:
void SetOutputChannel(System::Drawing::Imaging::ColorChannelFlag flags);
public void SetOutputChannel(System.Drawing.Imaging.ColorChannelFlag flags);
member this.SetOutputChannel : System.Drawing.Imaging.ColorChannelFlag -> unit
Public Sub SetOutputChannel (flags As ColorChannelFlag)
參數
- flags
- ColorChannelFlag
其中一個元素 ColorChannelFlag 指定輸出通道。
範例
以下程式碼範例示範如何使用此 SetOutputChannel 方法。 要執行此範例,請將以下程式碼貼上到 Windows 表單中。 處理該型態的Paint事件,並呼叫 ShowOutputChannels,通過 e 。PaintEventArgs
private void ShowOutputChannels(PaintEventArgs e)
{
//Create a bitmap from a file.
Bitmap bmp1 = new Bitmap("c:\\fakePhoto.jpg");
// Create a new bitmap from the original, resizing it for this example.
Bitmap bmp2 = new Bitmap(bmp1, new Size(80, 80));
bmp1.Dispose();
// Create an ImageAttributes object.
ImageAttributes imgAttributes = new ImageAttributes();
// Draw the image unaltered.
e.Graphics.DrawImage(bmp2, 10, 10);
// Draw the image, showing the intensity of the cyan channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelC,
System.Drawing.Imaging.ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(100, 10, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the magenta channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelM,
ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(10, 100, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the yellow channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelY,
ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(100, 100, bmp2.Width, bmp2.Height), 0, 0,
bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the black channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelK,
System.Drawing.Imaging.ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(10, 190, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
//Dispose of the bitmap.
bmp2.Dispose();
}
Private Sub ShowOutputChannels(ByVal e As PaintEventArgs)
'Create a bitmap from a file.
Dim bmp1 As New Bitmap("c:\fakePhoto.jpg")
' Create a new bitmap from the original, resizing it for this example.
Dim bmp2 As New Bitmap(bmp1, New Size(80, 80))
bmp1.Dispose()
' Create an ImageAttributes object.
Dim imgAttributes As New System.Drawing.Imaging.ImageAttributes()
' Draw the image unaltered.
e.Graphics.DrawImage(bmp2, 10, 10)
' Draw the image, showing the intensity of the cyan channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelC, ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(100, 10, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the magenta channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelM, ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(10, 100, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the yellow channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelY, _
ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(100, 100, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the black channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelK, _
ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(10, 190, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
'Dispose of the bitmap.
bmp2.Dispose()
End Sub
備註
你可以用這個 SetOutputChannel 方法將影像轉換成 CMYK 色彩空間,並檢查其中一個 CMYK 色彩通道的強度。 舉例來說,假設你建立一個 ImageAttributes 物件,並將其點陣圖輸出通道設為 ColorChannelC。 如果你把該 ImageAttributes 物件的路徑傳給方法, DrawImage 會計算出每個像素的青色分量,渲染影像中的每個像素都是灰色,代表其青色通道的強度。 同樣地,你也可以渲染出顯示洋紅、黃色和黑色通道強度的影像。
物件 ImageAttributes 會維持五個調整類別的色彩與灰階設定:預設、點陣圖、筆刷、筆觸和文字。 例如,你可以為預設類別指定輸出通道,為點陣類別指定不同的輸出通道。
默認色彩調整和灰階調整設定適用於沒有自己調整設定的所有類別。 例如,如果你從未為點陣圖類別指定任何調整設定,預設設定會套用到點陣圖類別。
適用於
SetOutputChannel(ColorChannelFlag, ColorAdjustType)
設定指定類別的CMYK(青-洋紅-黃-黑)輸出通道。
public:
void SetOutputChannel(System::Drawing::Imaging::ColorChannelFlag flags, System::Drawing::Imaging::ColorAdjustType type);
public void SetOutputChannel(System.Drawing.Imaging.ColorChannelFlag flags, System.Drawing.Imaging.ColorAdjustType type);
member this.SetOutputChannel : System.Drawing.Imaging.ColorChannelFlag * System.Drawing.Imaging.ColorAdjustType -> unit
Public Sub SetOutputChannel (flags As ColorChannelFlag, type As ColorAdjustType)
參數
- flags
- ColorChannelFlag
其中一個元素 ColorChannelFlag 指定輸出通道。
- type
- ColorAdjustType
其中的一個元素 ColorAdjustType 指定輸出通道所設定的類別。
範例
以下程式碼範例示範如何使用此 SetOutputChannel 方法。 要執行此範例,請將以下程式碼貼上到 Windows 表單中。 處理該型態的Paint事件,並呼叫 ShowOutputChannels,通過 e 。PaintEventArgs
private void ShowOutputChannels(PaintEventArgs e)
{
//Create a bitmap from a file.
Bitmap bmp1 = new Bitmap("c:\\fakePhoto.jpg");
// Create a new bitmap from the original, resizing it for this example.
Bitmap bmp2 = new Bitmap(bmp1, new Size(80, 80));
bmp1.Dispose();
// Create an ImageAttributes object.
ImageAttributes imgAttributes = new ImageAttributes();
// Draw the image unaltered.
e.Graphics.DrawImage(bmp2, 10, 10);
// Draw the image, showing the intensity of the cyan channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelC,
System.Drawing.Imaging.ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(100, 10, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the magenta channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelM,
ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(10, 100, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the yellow channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelY,
ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(100, 100, bmp2.Width, bmp2.Height), 0, 0,
bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
// Draw the image, showing the intensity of the black channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelK,
System.Drawing.Imaging.ColorAdjustType.Bitmap);
e.Graphics.DrawImage(bmp2, new Rectangle(10, 190, bmp2.Width, bmp2.Height),
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes);
//Dispose of the bitmap.
bmp2.Dispose();
}
Private Sub ShowOutputChannels(ByVal e As PaintEventArgs)
'Create a bitmap from a file.
Dim bmp1 As New Bitmap("c:\fakePhoto.jpg")
' Create a new bitmap from the original, resizing it for this example.
Dim bmp2 As New Bitmap(bmp1, New Size(80, 80))
bmp1.Dispose()
' Create an ImageAttributes object.
Dim imgAttributes As New System.Drawing.Imaging.ImageAttributes()
' Draw the image unaltered.
e.Graphics.DrawImage(bmp2, 10, 10)
' Draw the image, showing the intensity of the cyan channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelC, ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(100, 10, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the magenta channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelM, ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(10, 100, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the yellow channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelY, _
ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(100, 100, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
' Draw the image, showing the intensity of the black channel.
imgAttributes.SetOutputChannel(ColorChannelFlag.ColorChannelK, _
ColorAdjustType.Bitmap)
e.Graphics.DrawImage(bmp2, New Rectangle(10, 190, bmp2.Width, bmp2.Height), _
0, 0, bmp2.Width, bmp2.Height, GraphicsUnit.Pixel, imgAttributes)
'Dispose of the bitmap.
bmp2.Dispose()
End Sub
備註
你可以用這個 SetOutputChannel 方法將影像轉換成 CMYK 色彩空間,並檢查其中一個 CMYK 色彩通道的強度。 舉例來說,假設你建立一個 ImageAttributes 物件,並將其點陣圖輸出通道設為 ColorChannelC。 如果你把該 ImageAttributes 物件的路徑傳給方法, DrawImage 會計算出每個像素的青色分量,渲染影像中的每個像素都是灰色,代表其青色通道的強度。 同樣地,你也可以渲染出顯示洋紅、黃色和黑色通道強度的影像。
物件 ImageAttributes 會維持五個調整類別的色彩與灰階設定:預設、點陣圖、筆刷、筆觸和文字。 例如,你可以為預設類別指定輸出通道,為點陣類別指定不同的輸出通道。
默認色彩調整和灰階調整設定適用於沒有自己調整設定的所有類別。 例如,如果你從未為點陣圖類別指定任何調整設定,預設設定會套用到點陣圖類別。
一旦您指定特定類別的色彩調整或灰階調整設定,預設調整設定就不再套用至該類別。 例如,假設您指定預設類別的調整設定集合。 如果你透過傳遞 Bitmap 方法 SetOutputChannel 設定點陣圖類別的輸出通道,預設調整設定不會套用到點陣圖。