WinG Halftoning Sample

HALFTONE.EXE, found in the SAMPLES\HALFTONE subdirectory of the WinG development kit, dithers 24-bit DIBs to the WinG Halftone Palette using an 8x8 ordered dither.

The main function, DibHalftoneDIB in HALFTONE.C, does the real work in the dithering. The process of calculating an ordered dither is too complex to describe here, but a description of the techniques involved can be found in "Computer Graphics: Principles and Practice" by Foley, van Dam, Feiner, and Hughes. See the Further Reading article for more information on this book.

The aWinGHalftoneTranslation array found in HTTABLES.C converts a 2.6-bit-per-pixel computed halftone index into an entry in the halftone palette. To calculate the nearest match of an RGB color to the halftone palette, HALFTONE uses the following formula:

HalftoneIndex = (Red / 51) + (Green / 51) * 6 + (Blue / 51) * 36;

HalftoneColorIndex = aWinGHalftoneTranslation [HalftoneIndex];

See also the documentation for the WinGCreateHalftoneBrush function and the Halftoning With WinG article.