Color Separation

 

The SplitColorChannels function/method of the BiImage DLL/OCX splits an image into its separate color components. SplitColorChannels works for only 24 and 32 bit per pixel images.

 

[C++]

 

/* Splitting an image into separate color components*/

 

#include “BiImage.h”

 

int iRet;

HDIB* Images;

 

Images = (HDIB*)calloc(4,sizeof(HDIB*));

if (!Images)

return;

 

/* 1. parameter: Handle of the DIB to split

   2. parameter: Pointer to the DIBs

   3. parameter: Color format */

 

iRet = SplitColorChannels(hDib, Images, FORMAT_HSV);

 

if (iRet == 0)

{

            // Error

}

 

for (i = 0; i<4; i++)

            GlobalFree(Images[i]);

free(Images);

 

[VB]

 

‘ Splitting an image into separate color components

 

Dim BIimageObj as Object

Dim hDibRed as Long

Dim hDibBlue as Long

Dim hDibGreen as Long

Dim hDibBlack as Long

Dim iRet as Integer

 

Set BIImageObj = CreateObject("BIIMAGE.BIImageCtrl.1")

 

‘ 1. parameter: Handle of the DIB to split

‘ 2. parameter: Handle of DIB of Red component

‘ 3. parameter: Handle of DIB of Green component

‘ 4. parameter: Handle of DIB of Blue component

‘ 5. parameter: Handle of DIB of Black component

‘ 6. parameter: Color space format code

 

iRet = BIImageObj.SplitColorChannels(hDib, hDibRed, _ hDibBlue, hDibGreen, hDibBlack, CFRGB)

 

Set BIImageObj = Nothing

 

If iRet = 0 Then

            ‘ Error

End If

 

DropDIB hDibRed

DropDIB hDibBlue

DropDIB hDibGreen

DropDIB hDibBlack

 

[C#]

 

/* Splitting an image into separate color components*/

 

int hDibRed;

int hDibGreen;

int hDibBlue;

int hDibBlack;

int iRet;

 

hDibRed = 0;

hDibGreen = 0;

hDibBlue = 0;

hDibBlack = 0;

 

iRet = BiImage.SplitColorChannels(hDib, ref hDibRed, ref

hDibBlue, ref hDibGreen, ref hDibBlack,

(short)BIIMAGELib.ColorFormats.CFRGB)

 

if (iRet == 0)

{

            // Error

}

 

DropDIB(hDibRed);

DropDIB(hDibBlue);

DropDIB(hDibGreen);

DropDIB(hDibBlack);