0 Members and 1 Guest are viewing this topic.
Texture tmpTexture;tmpTexture.loadFromFile(tmp.str()); Sprite tmpSprite(tmpTexture);tmpSprite.setScale(width/tmpSprite.getLocalBounds().width, height/tmpSprite.getLocalBounds().height);
The thing is sf::Texture "lives" on the GPU, thus the best way would be to write a shader program.Otherwise you'll have to render the scaled sprite to a render texture and convert the extracted texture to an sf::Image to get to the pixel info. This can be slow.
Texture tmpTexture;tmpTexture.loadFromFile(tmp.str()); Sprite tmpSprite(tmpTexture);tmpSprite.setScale(width/tmpSprite.getLocalBounds().width, height/tmpSprite.getLocalBounds().height); sf::RenderTexture renderTexture;renderTexture.create(width, height);renderTexture.draw(tmpSprite); Texture t=renderTexture.getTexture();Image imageOut.... How do i convert?
Texture tmpTexture;tmpTexture.loadFromFile(tmp.str());Sprite tmpSprite(tmpTexture);tmpSprite.setScale(width/tmpSprite.getLocalBounds().width, height/tmpSprite.getLocalBounds().height);sf::RenderTexture renderTexture;renderTexture.create(width, height);renderTexture.draw(tmpSprite);Texture t=renderTexture.getTexture();Image imageOut =t.copyToImage();tmp.str("");tmp << "1" << entry->d_name;imageOut.saveToFile(tmp.str());cout << imageOut.getSize().x << endl;cout << imageOut.getSize().y << endl;tmp.str("");