fixed toolbar mapping bug (optimizer bug?) in the release build (bug 501485)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13555 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1102,6 +1102,38 @@ long wxToolBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
// private functions
|
// private functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
|
WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
|
||||||
{
|
{
|
||||||
// number of the colours we map: if you change this, update
|
// number of the colours we map: if you change this, update
|
||||||
@@ -1190,33 +1222,15 @@ WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
|
|||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MapColours(hdcMem, width, height, WXSIZEOF(ColorMap), ColorMap);
|
||||||
|
|
||||||
|
return bitmap;
|
||||||
|
|
||||||
// VZ: I leave here my attempts to map the bitmap to the system colours
|
// VZ: I leave here my attempts to map the bitmap to the system colours
|
||||||
// faster by using BitBlt() even though it's broken currently - but
|
// faster by using BitBlt() even though it's broken currently - but
|
||||||
// maybe someone else can finish it? It should be faster than iterating
|
// maybe someone else can finish it? It should be faster than iterating
|
||||||
// over all pixels...
|
// over all pixels...
|
||||||
#if 1
|
#if 0
|
||||||
for ( int i = 0; i < width; i++ )
|
|
||||||
{
|
|
||||||
for ( int j = 0; j < height; j++ )
|
|
||||||
{
|
|
||||||
COLORREF pixel = ::GetPixel(hdcMem, i, j);
|
|
||||||
|
|
||||||
for ( size_t k = 0; k < WXSIZEOF(ColorMap); k++ )
|
|
||||||
{
|
|
||||||
COLORREF col = ColorMap[k].from;
|
|
||||||
if ( abs(GetRValue(pixel) - GetRValue(col)) < 10 &&
|
|
||||||
abs(GetGValue(pixel) - GetGValue(col)) < 10 &&
|
|
||||||
abs(GetBValue(pixel) - GetBValue(col)) < 10 )
|
|
||||||
{
|
|
||||||
::SetPixel(hdcMem, i, j, ColorMap[k].to);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return bitmap;
|
|
||||||
#else // 1
|
|
||||||
MemoryHDC hdcMask, hdcDst;
|
MemoryHDC hdcMask, hdcDst;
|
||||||
if ( !hdcMask || !hdcDst )
|
if ( !hdcMask || !hdcDst )
|
||||||
{
|
{
|
||||||
@@ -1271,7 +1285,7 @@ WXHBITMAP wxToolBar::MapBitmap(WXHBITMAP bitmap, int width, int height)
|
|||||||
::DeleteObject((HBITMAP)bitmap);
|
::DeleteObject((HBITMAP)bitmap);
|
||||||
|
|
||||||
return (WXHBITMAP)hbmpDst;
|
return (WXHBITMAP)hbmpDst;
|
||||||
#endif // 0/1
|
#endif // 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_TOOLBAR && Win95
|
#endif // wxUSE_TOOLBAR && Win95
|
||||||
|
Reference in New Issue
Block a user