ImageAttributes.SetOutputChannel Metodo

Definizione

Imposta il canale di output CMYK.

Overload

SetOutputChannel(ColorChannelFlag)

Imposta il canale di output CMYK per la categoria predefinita.

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Imposta il canale di output CMYK per una categoria specificata.

SetOutputChannel(ColorChannelFlag)

Imposta il canale di output CMYK per la categoria predefinita.

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)

Parametri

flags
ColorChannelFlag

Elemento dell'oggetto ColorChannelFlag che specifica il canale di output.

Esempio

Nell'esempio di codice riportato di seguito viene illustrato come utilizzare il metodo SetOutputChannel. Per eseguire questo esempio, incollare il codice seguente in un Windows Form. Gestire l'evento del Paint modulo e chiamare ShowOutputChannels, passando e come 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

Commenti

È possibile usare il SetOutputChannel metodo per convertire un'immagine in uno spazio colore CMYK ed esaminare le intensità di uno dei canali di colore CMYK. Si supponga, ad esempio, di creare un ImageAttributes oggetto e impostare il canale di output bitmap su ColorChannelC. Se si passa il percorso di tale ImageAttributes oggetto al DrawImage metodo, viene calcolato il componente ciano di ogni pixel e ogni pixel nell'immagine di rendering è una sfumatura di grigio che indica l'intensità del canale ciano. Analogamente, è possibile eseguire il rendering delle immagini che indicano le intensità dei canali magenta, giallo e nero.

Un ImageAttributes oggetto gestisce le impostazioni di colore e scala di grigio per cinque categorie di regolazione: impostazione predefinita, bitmap, pennello, penna e testo. Ad esempio, è possibile specificare un canale di output per la categoria predefinita e un canale di output diverso per la categoria bitmap.

Le impostazioni predefinite di regolazione dei colori e di regolazione della scala grigia si applicano a tutte le categorie che non hanno impostazioni di regolazione personalizzate. Ad esempio, se non si specificano mai impostazioni di regolazione per la categoria bitmap, le impostazioni predefinite si applicano alla categoria bitmap.

Si applica a

SetOutputChannel(ColorChannelFlag, ColorAdjustType)

Imposta il canale di output CMYK per una categoria specificata.

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)

Parametri

flags
ColorChannelFlag

Elemento dell'oggetto ColorChannelFlag che specifica il canale di output.

type
ColorAdjustType

Elemento dell'oggetto ColorAdjustType da cui viene specificata la categoria per la quale viene impostato il canale di output.

Esempio

Nell'esempio di codice riportato di seguito viene illustrato come utilizzare il metodo SetOutputChannel. Per eseguire questo esempio, incollare il codice seguente in un Windows Form. Gestire l'evento del Paint modulo e chiamare ShowOutputChannels, passando e come 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

Commenti

È possibile usare il SetOutputChannel metodo per convertire un'immagine in uno spazio colore CMYK ed esaminare le intensità di uno dei canali di colore CMYK. Si supponga, ad esempio, di creare un ImageAttributes oggetto e impostare il canale di output bitmap su ColorChannelC. Se si passa il percorso di tale ImageAttributes oggetto al DrawImage metodo, viene calcolato il componente ciano di ogni pixel e ogni pixel nell'immagine di rendering è una sfumatura di grigio che indica l'intensità del canale ciano. Analogamente, è possibile eseguire il rendering delle immagini che indicano le intensità dei canali magenta, giallo e nero.

Un ImageAttributes oggetto gestisce le impostazioni di colore e scala di grigio per cinque categorie di regolazione: impostazione predefinita, bitmap, pennello, penna e testo. Ad esempio, è possibile specificare un canale di output per la categoria predefinita e un canale di output diverso per la categoria bitmap.

Le impostazioni predefinite di regolazione dei colori e di regolazione della scala grigia si applicano a tutte le categorie che non hanno impostazioni di regolazione personalizzate. Ad esempio, se non si specificano mai impostazioni di regolazione per la categoria bitmap, le impostazioni predefinite si applicano alla categoria bitmap.

Non appena si specifica un'impostazione di regolazione del colore o di regolazione della scala grigia per una determinata categoria, le impostazioni di regolazione predefinite non si applicano più a tale categoria. Si supponga, ad esempio, di specificare una raccolta di impostazioni di regolazione per la categoria predefinita. Se si imposta il canale di output per la categoria bitmap passando Bitmap al SetOutputChannel metodo, nessuna delle impostazioni di regolazione predefinite verrà applicata alle bitmap.

Si applica a