Color Separation

 

TheSplitColorChannels 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);

 

[C#]

 

/* Splitting an image into separate color components*/

 

long hDibRed;

long hDibGreen;

long hDibBlue;

long 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);