Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - littles

Pages: [1]
1
General / Change Cursor to Image
« on: December 11, 2018, 03:38:34 pm »
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-Cursor
Would the last solution work for me with pictures which have colours?

Pages: [1]