我想先说我是一个完整的C++新手。我不知道任何与它相关的词汇,所以如果这个问题很微不足道,我很抱歉,因为我现在没有正确的术语或短语来自己解决方案。旋转纹理sfml并保存输出到文件
当前玩这个代码我发现在github上从我的3ds捕获游戏。 https://github.com/Gotos/Cute3DSCapture/blob/master/main.cpp
我想添加旋转图像并将其保存到PNG文件的能力。
from main.cpp
around 267我试图添加以下功能。
sprite.setTexture(texture);
sprite.rotate(90);
texture = sprite.getTexture();
texture.copyToImage().saveToFile("Something/Place/img.png");
当前纹理和精灵定义如下。
sf::Texture texture;
sf::Sprite sprite;
当我尝试建立并运行我得到的跟随着
main.cpp:269:25: error: no viable overloaded '='
texture = sprite.getTexture();
~~~~~~~^~~~~~~~~~~~~~~~~~~~
/usr/local/include/SFML/Graphics/Texture.hpp:421:14: note: candidate function
not viable: no known conversion from 'const sf::Texture *' to
'const sf::Texture' for 1st argument; dereference the argument with *
Texture& operator =(const Texture& right);
任何帮助将不胜感激。
也许试试'sprite.getTexture() - > copyToImage()。saveToFile(“Something/Place/img.png”);'直接 – MiMo
@MiMo这将简单地产生原始图像的副本,而不是修改版本。详情请参阅下面的答案。 – Hiura