Hello,
i'm trying to change the cursor image using sf::Cursor loadFromPixels (...).
It compiles without problems, but the result shows strange white lines in the cursor.
Im using the latest Ubuntu version.
My Code:
#include "CPP.hpp"
#include "SFML.hpp"
int main(int argc, char const *argv[])
{
sf::RenderWindow renderWindow(sf::VideoMode(900, 600, 32), "cur", sf::Style::None);
sf::Image curimg;
curimg.loadFromFile("cursor.png");
sf::Cursor cur;
cur.loadFromPixels(curimg.getPixelsPtr(), curimg.getSize(), sf::Vector2u(0,0));
renderWindow.setMouseCursor(cur);
while(renderWindow.isOpen()) {
sf::Event event;
while(renderWindow.pollEvent(event))
if(event.type == sf::Event::Closed)
renderWindow.close();
renderWindow.clear(sf::Color::White);
renderWindow.display();
}
return 0;
}
In the attachment you can find the image that i used.
I think it remains to the warning in the documentation
https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Cursor.php#ac24ecf82ac7d9ba6703389397f948b3aOn 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.
But i dont know how to fix this, or is there a workaround?
Thanks