I currently struggle a bit with changing the mouse cursor with the new Cursor API. I use an image which loads its content from a file. The image never gets out of scope, it is always loaded. So this is definitely not the problem.
[...]
mouse_cursor_1_image.loadFromFile("img/cursor_1.png");
[...]
mouse_cursor_1.loadFromPixels(
mouse_cursor_1_image.getPixelsPtr(),
Vector2u(mouse_cursor_1_image.getSize().x, mouse_cursor_1_image.getSize().x),
Vector2u(0, 0)
);
[...]
This almost works as expected. The mouse cursor changed, the shape is correct, but the cursor itself is only transparent, black and white (not even grey).
I am using Linux and I think the problem is related to the warning on this site:
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Cursor.php#ac24ecf82ac7d9ba6703389397f948b3a"Warning
On Unix, the pixels are mapped into a monochrome bitmap: pixels with an alpha channel to 0 are transparent, black if the RGB channel are close to zero, and white otherwise."
The really weird thing is that even some black pixels aren't black anymore. Some black pixels became white.
Is there any workaround? Besides using a texture+sprite instead of the real system mouse cursor? Because this turned out to not be as fast as I want it to be. I found this tutorial from SFML:
https://github.com/SFML/SFML/wiki/Tutorial:-Change-CursorWould the last solution work for me with pictures which have colours?