ImageGear v26.5 - Updated
ImageGear.Core Assembly / ImageGear.Processing Namespace / ImGearRasterProcessing Class / RemoveChannel Method
Page to remove channel.
Position of the channel to be removed.
Example




In This Topic
    RemoveChannel Method
    In This Topic
    Removes the specified channel from the page's DIB and shifts remaining channels without transforming pixel data.
    Syntax
    'Declaration
     
    Public Shared Sub RemoveChannel( _
       ByVal page As ImGearRasterPage, _
       ByVal channelNumber As Integer _
    ) 
    'Usage
     
    Dim page As ImGearRasterPage
    Dim channelNumber As Integer
     
    ImGearRasterProcessing.RemoveChannel(page, channelNumber)
    public static void RemoveChannel( 
       ImGearRasterPage page,
       int channelNumber
    )
    public: static void RemoveChannel( 
       ImGearRasterPage* page,
       int channelNumber
    ) 
    public:
    static void RemoveChannel( 
       ImGearRasterPage^ page,
       int channelNumber
    ) 

    Parameters

    page
    Page to remove channel.
    channelNumber
    Position of the channel to be removed.
    Remarks
    channelNumber can be within the [0..ChannelCount-1] range.

    Color Space is changed as follows:

    • If page has more than one Extra channel, color space is unchanged.
    • If page has one Extra channel, ExtraMask is cleared.
    • If page has Alpha channel and no Extra channels, AlphaMask and PremultAlphaMask are cleared.
    • If page has only color channels, color space is changed to Unknown, and all remaining channels are considered Extra channels.
    Example
    // Separate image into separate images for each channel.
    ImGearChannelRef[] igChannelRef = ImGearRasterProcessing.SeparateChannels(igRasterPage);
    // Remove the alpha channel from an RGBA image.
    ImGearRasterProcessing.RemoveChannel(igRasterPage, 3);
    // Save the page out without the alpha channel.
    using (FileStream localFile = new FileStream("withoutalpha.jpg", FileMode.Create))
    {
        ImGearFileFormats.SavePage(igRasterPage,localFile, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG);
    }
    //Set the colorspace to RGBA again.
    ImGearRasterProcessing.ConvertColorSpace(
        igRasterPage, new ImGearColorSpace(ImGearColorSpaceIDs.RGBA));
    // Add the alpha channel back to the image.
    ImGearRasterProcessing.InsertChannel(igRasterPage, 3, igChannelRef[3]);
    // Remove the alpha channel added by the colorspace conversion.
    ImGearRasterProcessing.RemoveChannel(igRasterPage, 4);
    ' Separate image into separate images for each channel.
    Dim igChannelRef As ImGearChannelRef() = ImGearRasterProcessing.SeparateChannels(igRasterPage)
    ' Remove the alpha channel from an RGBA image.
    ImGearRasterProcessing.RemoveChannel(igRasterPage, 3)
    ' Save the page out without the alpha channel.
    Using localFile As New FileStream("withoutalpha.jpg", FileMode.Create)
        ImGearFileFormats.SavePage(igRasterPage, localFile, 0, ImGearSavingModes.OVERWRITE, ImGearSavingFormats.JPG)
    End Using
    'Set the colorspace to RGBA again.
    ImGearRasterProcessing.ConvertColorSpace(igRasterPage, New ImGearColorSpace(ImGearColorSpaceIDs.RGBA))
    ' Add the alpha channel back to the image.
    ImGearRasterProcessing.InsertChannel(igRasterPage, 3, igChannelRef(3))
    ' Remove the alpha channel added by the colorspace conversion.
    ImGearRasterProcessing.RemoveChannel(igRasterPage, 4)
    See Also