There are two functions or methods in BiDib DLL or OCX to convert an image to grayscale with antialiasing. The name of the functions are ConvertMonoDIBtoGrayscale and ConvColorDIBtoGrayscale. You can use these functions to convert the DIB to grayscale before displaying.
[C++]
#include “BiDib.h”
void CMyView::Convert(HDIB hDib)
{
HDIB hDibNew;
if (!hDib)
return;
// The DIB is monochrome or not
if (IsMono(hDib))
// 1. parameter: Handle of the DIB
// 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
hDibNew = ConvertMonoDIBtoGrayscale(hDib, 1);
else
// 1. parameter: Handle of the DIB
// 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
// 3. parameter: TRUE: the resulted (gray) pixel value is the weighted sum of 'red',
// 'green' and 'blue' components.
// FALSE: the resulted (gray) pixel value is the simple average of
// colour components.
hDibNew = ConvColorDIBtoGrayscale(hDib, 1, TRUE);
if (!hDibNew)
{
// Error
}
}
[VB]
Private Sub Convert(hDib As Long)
Dim BiDibObj As Object
Dim hDibNew As Long
If hDib = 0 Then
Exit Sub
End If
Set BiDibObj = CreateObject("BIDIB.BIDIBCtrl.1")
If BiDisp.ColorDepth = 1 Then
‘ 1. parameter: Handle of the DIB
‘ 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
hDibNew = BiDibObj.ConvertMonoDIBToGrayScale(BiDisp.hdib, 1)
Else
‘ 1. parameter: Handle of the DIB
‘ 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
‘ 3. parameter: True: the resulted (gray) pixel value is the weighted sum of 'red',
‘ 'green' and 'blue' components.
‘ False: the resulted (gray) pixel value is the simple average of
‘ colour components.
hDibNew = BiDibObj.ConvColorDIBToGrayScale(BiDisp.hdib, 1, True)
End If
Set BiDibObj = Nothing
If hDibNew = 0 Then
‘Error
End If
End Sub
[C#]
private void Convert(int hDib)
{
int hDibNew = 0;
if (hDib == 0)
return;
if (BiDisp.ColorDepth == 1)
// 1. parameter: Handle of the DIB
// 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
hDibNew = BiDib.ConvertMonoDIBToGrayscale(hDib, 1);
else
// 1. parameter: Handle of the DIB
// 2. parameter: Antialiasing method (antialiasing with 3x3 resampling area)
// 3. parameter: TRUE: the resulted (gray) pixel value is the weighted sum of 'red',
// 'green' and 'blue' components.
// FALSE: the resulted (gray) pixel value is the simple average of
// colour components.
hDibNew = BiDib.ConvColorDIBToGrayscale(hDib, 1, true);
if (!hDibNew)
{
// Error
}
}