ImageGear .NET - Updated
InsertChannel Method
Example 




ImageGear24.Core Assembly > ImageGear.Processing Namespace > ImGearRasterProcessing Class : InsertChannel Method
Page to insert channel to.
Position of the channel in the page.
Reference to the channel to be inserted.
Inserts a channel to the page's DIB and changes page's color space.
Syntax
'Declaration
 
Public Shared Sub InsertChannel( _
   ByVal page As ImGearRasterPage, _
   ByVal newChannelPos As Integer, _
   ByVal channel As ImGearChannelRef _
) 
'Usage
 
Dim page As ImGearRasterPage
Dim newChannelPos As Integer
Dim channel As ImGearChannelRef
 
ImGearRasterProcessing.InsertChannel(page, newChannelPos, channel)
public static void InsertChannel( 
   ImGearRasterPage page,
   int newChannelPos,
   ImGearChannelRef channel
)
public: static void InsertChannel( 
   ImGearRasterPage* page,
   int newChannelPos,
   ImGearChannelRef channel
) 
public:
static void InsertChannel( 
   ImGearRasterPage^ page,
   int newChannelPos,
   ImGearChannelRef channel
) 

Parameters

page
Page to insert channel to.
newChannelPos
Position of the channel in the page.
channel
Reference to the channel to be inserted.
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

Reference

ImGearRasterProcessing Class
ImGearRasterProcessing Members
ImGearRasterPage Class
ImGearChannelRef Structure