ImageAttributes.SetOutputChannel Método

Definição

Define o canal de saída CMYK (cyan-magenta-yellow-black).

Sobrecargas

Nome Description
SetOutputChannel(ColorChannelFlag)

Define o canal de saída CMYK (cyan-magenta-yellow-black) para a categoria padrão.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Define o canal de saída CMYK (cyan-magenta-yellow-black) para uma categoria especificada.

SetOutputChannel(ColorChannelFlag)

Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs

Define o canal de saída CMYK (cyan-magenta-yellow-black) para a categoria padrão.

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)

Parâmetros

flags
ColorChannelFlag

Um elemento que especifica o canal de ColorChannelFlag saída.

Exemplos

O exemplo de código a seguir demonstra como usar o SetOutputChannel método. Para executar este exemplo, cole o código a seguir em um formulário Windows. Manipule o evento e a chamada Paintdo ShowOutputChannels formulário, passando e como 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

Comentários

Você pode usar o SetOutputChannel método para converter uma imagem em um espaço de cores CMYK e examinar as intensidades de um dos canais de cores do CMYK. Por exemplo, suponha que você crie um ImageAttributes objeto e defina seu canal de saída de bitmap como ColorChannelC. Se você passar o caminho desse ImageAttributes objeto para o DrawImage método, o componente de ciano de cada pixel será calculado e cada pixel na imagem renderizada será um tom de cinza que indica a intensidade de seu canal de ciano. Da mesma forma, você pode renderizar imagens que indicam as intensidades dos canais magenta, amarelo e preto.

Um ImageAttributes objeto mantém as configurações de cor e escala de cinza para cinco categorias de ajuste: padrão, bitmap, pincel, caneta e texto. Por exemplo, você pode especificar um canal de saída para a categoria padrão e um canal de saída diferente para a categoria bitmap.

As configurações padrão de ajuste de cor e ajuste de escala de cinza se aplicam a todas as categorias que não têm configurações de ajuste próprias. Por exemplo, se você nunca especificar nenhuma configuração de ajuste para a categoria bitmap, as configurações padrão se aplicarão à categoria bitmap.

Aplica-se a

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs
Origem:
ImageAttributes.cs

Define o canal de saída CMYK (cyan-magenta-yellow-black) para uma categoria especificada.

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)

Parâmetros

flags
ColorChannelFlag

Um elemento que especifica o canal de ColorChannelFlag saída.

type
ColorAdjustType

Um elemento que ColorAdjustType especifica a categoria para a qual o canal de saída está definido.

Exemplos

O exemplo de código a seguir demonstra como usar o SetOutputChannel método. Para executar este exemplo, cole o código a seguir em um formulário Windows. Manipule o evento e a chamada Paintdo ShowOutputChannels formulário, passando e como 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

Comentários

Você pode usar o SetOutputChannel método para converter uma imagem em um espaço de cores CMYK e examinar as intensidades de um dos canais de cores do CMYK. Por exemplo, suponha que você crie um ImageAttributes objeto e defina seu canal de saída de bitmap como ColorChannelC. Se você passar o caminho desse ImageAttributes objeto para o DrawImage método, o componente de ciano de cada pixel será calculado e cada pixel na imagem renderizada será um tom de cinza que indica a intensidade de seu canal de ciano. Da mesma forma, você pode renderizar imagens que indicam as intensidades dos canais magenta, amarelo e preto.

Um ImageAttributes objeto mantém as configurações de cor e escala de cinza para cinco categorias de ajuste: padrão, bitmap, pincel, caneta e texto. Por exemplo, você pode especificar um canal de saída para a categoria padrão e um canal de saída diferente para a categoria bitmap.

As configurações padrão de ajuste de cor e ajuste de escala de cinza se aplicam a todas as categorias que não têm configurações de ajuste próprias. Por exemplo, se você nunca especificar nenhuma configuração de ajuste para a categoria bitmap, as configurações padrão se aplicarão à categoria bitmap.

Assim que você especificar uma configuração de ajuste de cor ou ajuste de escala de cinza para uma determinada categoria, as configurações de ajuste padrão não se aplicam mais a essa categoria. Por exemplo, suponha que você especifique uma coleção de configurações de ajuste para a categoria padrão. Se você definir o canal de saída para a categoria bitmap passando Bitmap para o SetOutputChannel método, nenhuma das configurações de ajuste padrão será aplicada a bitmaps.

Aplica-se a