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.OCX) or Desaturating (Desaturate implemented in BIIMAGE.OCX). Antialising can only be applied to a 8 bit per pixel color images. If a 24 bit per pixel color image is to be converted to grayscale, first use a dithering function and after that use antialising. Desaturating methods can be applied on both 8 bit per pixel and 24 bit per pixel images.
Code example:
Dim hSourceDib As Long
Dim hResDib As Long
Dim BIImageObj As Object
‘ Load the input image
…
Set BIImageObj = CreateObject("BIIMAGE.BIImageCtrl.1")
hResDib = BIImageObj.Desaturate(hSourceDib, DispBoth, hWnd)
Set BIImageObj = Nothing