-// VZ: we use a separate function to do the actual colour mapping because
-// otherwise VC++ optimizer seems to mangle the code in MapBitmap(): with
-// optimization on, the code produces incorrect result (but it's ok in
-// debug mode, i.e. globally without optimizations or if you insert a
-// #pragma optimize("", off) just before the function!)
-//
-// This will also make it simpler to replace MapColours() later with
-// something more efficient...
-static void MapColours(HDC hdc, int width, int height,
- size_t numColours, COLORMAP *cmap)
-{
- for ( int i = 0; i < width; i++ )
- {
- for ( int j = 0; j < height; j++ )
- {
- COLORREF pixel = ::GetPixel(hdc, i, j);
-
- for ( size_t k = 0; k < numColours; k++ )
- {
- COLORREF col = cmap[k].from;
- if ( abs(GetRValue(pixel) - GetRValue(col)) < 10 &&
- abs(GetGValue(pixel) - GetGValue(col)) < 10 &&
- abs(GetBValue(pixel) - GetBValue(col)) < 10 )
- {
- ::SetPixel(hdc, i, j, cmap[k].to);
- break;
- }
- }
- }
- }
-}
-