ImageAttributes.SetOutputChannel 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置 CMYK(青色-洋红色-黄色-黑色)输出通道。
重载
| SetOutputChannel(ColorChannelFlag) | 为默认类别设置 CMYK(青色-洋红色-黄色-黑色)输出通道。 | 
| SetOutputChannel(ColorChannelFlag, ColorAdjustType) | 为指定的类别设置 CMYK(青色-洋红色-黄色-黑色)输出通道。 | 
SetOutputChannel(ColorChannelFlag)
- Source:
- ImageAttributes.cs
- Source:
- ImageAttributes.cs
- Source:
- ImageAttributes.cs
为默认类别设置 CMYK(青色-洋红色-黄色-黑色)输出通道。
public:
 void SetOutputChannel(System::Drawing::Imaging::ColorChannelFlag flags);public void SetOutputChannel (System.Drawing.Imaging.ColorChannelFlag flags);member this.SetOutputChannel : System.Drawing.Imaging.ColorChannelFlag -> unitPublic Sub SetOutputChannel (flags As ColorChannelFlag)参数
- flags
- ColorChannelFlag
ColorChannelFlag 的一个元素,指定输出通道。
示例
下面的代码示例演示如何使用 SetOutputChannel 方法。 若要运行此示例,请将以下代码粘贴到 Windows 窗体中。 处理窗体的事件 Paint 并调用 ShowOutputChannels,作为 ePaintEventArgs传递。
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)
- Source:
- ImageAttributes.cs
- Source:
- ImageAttributes.cs
- Source:
- ImageAttributes.cs
为指定的类别设置 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 -> unitPublic Sub SetOutputChannel (flags As ColorChannelFlag, type As ColorAdjustType)参数
- flags
- ColorChannelFlag
ColorChannelFlag 的一个元素,指定输出通道。
- type
- ColorAdjustType
ColorAdjustType 的一个元素,指定将设置输出通道的类别。
示例
下面的代码示例演示如何使用 SetOutputChannel 方法。 若要运行此示例,请将以下代码粘贴到 Windows 窗体中。 处理窗体的事件 Paint 并调用 ShowOutputChannels,作为 ePaintEventArgs传递。
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 调整类别的颜色和灰度设置:默认、位图、画笔、笔和文本。 例如,可以为默认类别指定输出通道,为位图类别指定其他输出通道。
默认颜色调整和灰度调整设置适用于没有自己调整设置的所有类别。 例如,如果从未为位图类别指定任何调整设置,则默认设置将应用于位图类别。
为特定类别指定颜色调整或灰度调整设置后,默认调整设置将不再应用于该类别。 例如,假设为默认类别指定调整设置的集合。 如果通过传递给 BitmapSetOutputChannel 方法设置位图类别的输出通道,则默认调整设置都不会应用于位图。