Converting color images to grayscale

Q:  How can I convert a color image to grayscale?

A:  Converting a color image to grayscale can be done by Antialising (ConvColorDIBtoGrayScale implemented in BIDIB.Dll) or Desaturating (Desaturate implemented in BIIMAGE.Dll). Antialising can only be applied to an 8 bit per pixel color image. If a 24 bit per pixel color image is to be converted to grayscale, first use a dithering function and then use the antialising. Desaturating functions can be applied on both 8 bit per pixel and 24 bit per pixel images.

 

Code example:

     #include “BiImage.h”

     HANDLE hSourceDib = NULL;

     //     Load the input image

     …

     HDIB DitheredDIB = Desaturate(hSourceDib, DISPLAY_BOTH, AfxGetMainWnd()->m_hWnd);

     //     Further processing