The FilterPosterizing function/method of the BiFilter DLL/OCX can be used to posterize an image to reduce the color levels.
[C++]
/* Posterizing an image */
#include “BiFilter.h”
#include “BiImage.h”
HDIB hDibNew;
/* 1. parameter: Handle of the DIB to filter
2. parameter: Level
3. parameter: Show progress
4. parameter: Handle of parent window */
hDibNew = FilterPosterizing(hDib, 20, DISPLAY_BOTH,
AfxGetMainWnd()->m_hWnd);
if (!hDibNew)
{
// Error
}
[C#]
/* Posterizing an image */
long hDibNew;
/* 1. parameter: Handle of the DIB to filter
2. parameter: Level
3. parameter: Show progress
4. parameter: Handle of parent window */
hDibNew = BiFilter.FilterPosterizing(hDib, 20, Convert.ToInt16(BIFILTERLib.enumDisplayModes.DispBoth),
Handle.ToInt64());
if (hDibNew == 0)
{
// Error
}