ImageAttributes.SetOutputChannel Метод

Определение

Задает канал вывода CMYK (cyan-magenta-yellow-black).

Перегрузки

Имя Описание
SetOutputChannel(ColorChannelFlag)

Задает выходной канал CMYK (cyan-magenta-yellow-black) для категории по умолчанию.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Задает выходной канал CMYK (cyan-magenta-yellow-black) для указанной категории.

SetOutputChannel(ColorChannelFlag)

Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs

Задает выходной канал CMYK (cyan-magenta-yellow-black) для категории по умолчанию.

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)

Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs
Исходный код:
ImageAttributes.cs

Задает выходной канал CMYK (cyan-magenta-yellow-black) для указанной категории.

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 метод, ни один из параметров корректировки по умолчанию не будет применяться к растровым изображениям.

Применяется к