ImageAttributes.SetOutputChannel Metoda

Definice

Nastaví výstupní kanál CMYK (azurová-purpurová-žlutá-černá).

Přetížení

SetOutputChannel(ColorChannelFlag)

Nastaví výstupní kanál CMYK (azurová-purpurová-žlutá-černá) pro výchozí kategorii.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Nastaví výstupní kanál CMYK (azurová-purpurová-žlutá-černá) pro zadanou kategorii.

SetOutputChannel(ColorChannelFlag)

Zdroj:
ImageAttributes.cs
Zdroj:
ImageAttributes.cs
Zdroj:
ImageAttributes.cs

Nastaví výstupní kanál CMYK (azurová-purpurová-žlutá-černá) pro výchozí kategorii.

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

Prvek , ColorChannelFlag který určuje výstupní kanál.

Příklady

Následující příklad kódu ukazuje, jak použít metodu SetOutputChannel . Chcete-li spustit tento příklad, vložte do formuláře Windows Form následující kód. Zpracování události formuláře Paint a volání ShowOutputChannels, předání 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

Poznámky

Pomocí metody můžete SetOutputChannel převést obrázek na barevný prostor CMYK a prozkoumat intenzity jednoho z barevných kanálů CMYK. Předpokládejme například, že vytvoříte ImageAttributes objekt a nastavíte jeho výstupní kanál rastrového obrázku na ColorChannelChodnotu . Pokud předáte cestu ImageAttributes tohoto objektu DrawImage metodě, vypočítá se azurová komponenta každého pixelu a každý pixel ve vykresleném obrázku je odstín šedé, který označuje intenzitu jeho azurového kanálu. Podobně můžete vykreslit obrázky, které označují intenzitu purpurových, žlutých a černých kanálů.

Objekt ImageAttributes zachovává nastavení barev a stupňů šedé pro pět kategorií úprav: výchozí, rastrový obrázek, štětec, pero a text. Můžete například zadat výstupní kanál pro výchozí kategorii a jiný výstupní kanál pro kategorii rastrového obrázku.

Výchozí nastavení úprav barev a úprav stupňů šedé platí pro všechny kategorie, které nemají vlastní nastavení úprav. Pokud například nikdy nezadáte žádné nastavení úprav pro kategorii rastrového obrázku, použije se výchozí nastavení pro kategorii rastrových obrázků.

Platí pro

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Zdroj:
ImageAttributes.cs
Zdroj:
ImageAttributes.cs
Zdroj:
ImageAttributes.cs

Nastaví výstupní kanál CMYK (azurová-purpurová-žlutá-černá) pro zadanou 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

Prvek , ColorChannelFlag který určuje výstupní kanál.

type
ColorAdjustType

Prvek, ColorAdjustType který určuje kategorii, pro kterou je nastaven výstupní kanál.

Příklady

Následující příklad kódu ukazuje, jak použít metodu SetOutputChannel . Chcete-li spustit tento příklad, vložte do formuláře Windows Form následující kód. Zpracování události formuláře Paint a volání ShowOutputChannels, předání 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

Poznámky

Pomocí metody můžete SetOutputChannel převést obrázek na barevný prostor CMYK a prozkoumat intenzity jednoho z barevných kanálů CMYK. Předpokládejme například, že vytvoříte ImageAttributes objekt a nastavíte jeho výstupní kanál rastrového obrázku na ColorChannelChodnotu . Pokud předáte cestu ImageAttributes tohoto objektu DrawImage metodě, vypočítá se azurová komponenta každého pixelu a každý pixel ve vykresleném obrázku je odstín šedé, který označuje intenzitu jeho azurového kanálu. Podobně můžete vykreslit obrázky, které označují intenzitu purpurových, žlutých a černých kanálů.

Objekt ImageAttributes zachovává nastavení barev a stupňů šedé pro pět kategorií úprav: výchozí, rastrový obrázek, štětec, pero a text. Můžete například zadat výstupní kanál pro výchozí kategorii a jiný výstupní kanál pro kategorii rastrového obrázku.

Výchozí nastavení úprav barev a úprav stupňů šedé platí pro všechny kategorie, které nemají vlastní nastavení úprav. Pokud například nikdy nezadáte žádné nastavení úprav pro kategorii rastrového obrázku, použije se výchozí nastavení pro kategorii rastrových obrázků.

Jakmile pro určitou kategorii zadáte nastavení úpravy barev nebo stupňů šedé, výchozí nastavení úprav se už na tuto kategorii nevztahují. Předpokládejme například, že zadáte kolekci nastavení úprav pro výchozí kategorii. Pokud nastavíte výstupní kanál pro kategorii rastru předáním Bitmap do SetOutputChannel metody, žádné výchozí nastavení úprav nebude platit pro rastrové obrázky.

Platí pro