Correct creation of the mask for wxImage cursors in wxGTK.
The code created the monochrome bitmap used by wxCursor(wxImage) ctor incorrectly resulting in bad cursor appearance. Use the right values for foreground and background pixels (which are inversed compared to naive expectations) to fix this. Closes #11989. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -257,20 +257,17 @@ void wxCursor::InitFromImage( const wxImage & image )
|
||||
|
||||
// modify image so wxBitmap can be used to convert to pixmap
|
||||
image_copy.SetMask(false);
|
||||
int i, j;
|
||||
wxByte* data = image_copy.GetData();
|
||||
for (j = 0; j < h; j++)
|
||||
for (int j = 0; j < h; j++)
|
||||
{
|
||||
for (i = 0; i < w; i++, data += 3)
|
||||
for (int i = 0; i < w; i++, data += 3)
|
||||
{
|
||||
//if average value is > mid grey
|
||||
if (int(data[0]) + data[1] + data[2] >= 3 * 128)
|
||||
{
|
||||
// wxBitmap only converts (255,255,255) to white
|
||||
data[0] = 255;
|
||||
data[1] = 255;
|
||||
data[2] = 255;
|
||||
}
|
||||
// if average value of the pixel is > mid grey, convert it to
|
||||
// background (0), otherwise to foreground (255, using wxBitmap
|
||||
// convention)
|
||||
data[0] =
|
||||
data[1] =
|
||||
data[2] = int(data[0]) + data[1] + data[2] >= 3 * 128 ? 0 : 255;
|
||||
}
|
||||
}
|
||||
wxBitmap bitmap(image_copy, 1);
|
||||
|
Reference in New Issue
Block a user