///////////////////////////////////////////////////////////////////
// Function name : ZoomOutBmp
// Description : creates a new bitmap which is a grayscale
// zoomed out version of the original
// Return type : HDIB - handle to a new bitmap
// Argument : double zoom - number of times to zoom out
// Argument : HDIB hSrcDIB - handle to a source bitmap
///////////////////////////////////////////////////////////////////
HDIB ZoomOutBmp(double zoom, HDIB hSrcDIB)
{
if (hSrcDIB == NULL) // nothing to do
return NULL;
if (zoom < 1) // no zoomin in this function
return NULL;
// now fill the bits
LPSTR curSrcLineBits, curDstLineBits;
int j, k;
int scale = (int)(zoom + 0.5); // integer zoom out factor, i.e. 1:5
int hBase, vBase;
unsigned char value;
// for every _scale_ lines in a source bitmap we will get one line
// in the destination bitmap. Similarly for _scale_ columns in the
// source we'll obtain one destination column.
for (int strip=0; strip < bmihDst.biHeight; strip++) { // for every dst line
This function may be improved in several ways, for example, working with a weighted fraction of a pixel or centering the accumulated source pixels. However, the resulting visual impovement is not significant.