ImageAttributes.SetOutputChannel Metoda

Definicja

Ustawia kanał wyjściowy CMYK (cyan-magenta-yellow-black).

Przeciążenia

SetOutputChannel(ColorChannelFlag)

Ustawia kanał wyjściowy CMYK (cyan-magenta-yellow-black) dla kategorii domyślnej.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Ustawia kanał wyjściowy CMYK (cyan-magenta-yellow-black) dla określonej kategorii.

SetOutputChannel(ColorChannelFlag)

Źródło:
ImageAttributes.cs
Źródło:
ImageAttributes.cs
Źródło:
ImageAttributes.cs

Ustawia kanał wyjściowy CMYK (cyan-magenta-yellow-black) dla kategorii domyślnej.

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)

Parametry

flags
ColorChannelFlag

Element tego elementu ColorChannelFlag określa kanał wyjściowy.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać SetOutputChannel metody . Aby uruchomić ten przykład, wklej następujący kod do formularza systemu Windows. Obsłuż zdarzenie formularza Paint i wywołaj ShowOutputChannelsmetodę , przekazując e jako 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

Uwagi

Możesz użyć SetOutputChannel metody , aby przekonwertować obraz na przestrzeń kolorów CMYK i zbadać intensyjność jednego z kanałów kolorów CMYK. Załóżmy na przykład, że utworzysz ImageAttributes obiekt i ustawisz jego kanał wyjściowy mapy bitowej na ColorChannelC. Jeśli przekazujesz ścieżkę tego ImageAttributes obiektu do DrawImage metody, składnik cyjanowy każdego piksela jest obliczany, a każdy piksel na renderowanym obrazie jest odcieniem szarości, który wskazuje intensywność jego kanału cyjanowego. Podobnie można renderować obrazy, które wskazują na intensyfikacje magenty, żółtych i czarnych kanałów.

Obiekt ImageAttributes zachowuje ustawienia koloru i skali szarości dla pięciu kategorii korekt: domyślne, mapy bitowe, pędzle, pióro i tekst. Na przykład można określić kanał wyjściowy dla kategorii domyślnej i inny kanał wyjściowy dla kategorii mapy bitowej.

Domyślne ustawienia dostosowania kolorów i skali szarości mają zastosowanie do wszystkich kategorii, które nie mają własnych ustawień regulacji. Jeśli na przykład nigdy nie określisz żadnych ustawień korekty dla kategorii mapy bitowej, ustawienia domyślne będą stosowane do kategorii mapy bitowej.

Dotyczy

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Źródło:
ImageAttributes.cs
Źródło:
ImageAttributes.cs
Źródło:
ImageAttributes.cs

Ustawia kanał wyjściowy CMYK (cyan-magenta-yellow-black) dla określonej kategorii.

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)

Parametry

flags
ColorChannelFlag

Element tego elementu ColorChannelFlag określa kanał wyjściowy.

type
ColorAdjustType

Element ColorAdjustType tego określa kategorię, dla której ustawiono kanał wyjściowy.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać SetOutputChannel metody . Aby uruchomić ten przykład, wklej następujący kod do formularza systemu Windows. Obsłuż zdarzenie formularza Paint i wywołaj ShowOutputChannelsmetodę , przekazując e jako 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

Uwagi

Możesz użyć SetOutputChannel metody , aby przekonwertować obraz na przestrzeń kolorów CMYK i zbadać intensyjność jednego z kanałów kolorów CMYK. Załóżmy na przykład, że utworzysz ImageAttributes obiekt i ustawisz jego kanał wyjściowy mapy bitowej na ColorChannelC. Jeśli przekazujesz ścieżkę tego ImageAttributes obiektu do DrawImage metody, składnik cyjanowy każdego piksela jest obliczany, a każdy piksel na renderowanym obrazie jest odcieniem szarości, który wskazuje intensywność jego kanału cyjanowego. Podobnie można renderować obrazy, które wskazują na intensyfikacje magenty, żółtych i czarnych kanałów.

Obiekt ImageAttributes zachowuje ustawienia koloru i skali szarości dla pięciu kategorii korekt: domyślne, mapy bitowe, pędzle, pióro i tekst. Na przykład można określić kanał wyjściowy dla kategorii domyślnej i inny kanał wyjściowy dla kategorii mapy bitowej.

Domyślne ustawienia dostosowania kolorów i skali szarości mają zastosowanie do wszystkich kategorii, które nie mają własnych ustawień regulacji. Jeśli na przykład nigdy nie określisz żadnych ustawień korekty dla kategorii mapy bitowej, ustawienia domyślne będą stosowane do kategorii mapy bitowej.

Gdy tylko określisz ustawienie korekty koloru lub skali szarości dla określonej kategorii, domyślne ustawienia korekty nie będą już stosowane do tej kategorii. Załóżmy na przykład, że określisz kolekcję ustawień korekty dla kategorii domyślnej. Jeśli ustawisz kanał wyjściowy dla kategorii mapy bitowej, przechodząc Bitmap do SetOutputChannel metody , żadne z domyślnych ustawień regulacji nie będzie miało zastosowania do map bitowych.

Dotyczy