【发布时间】:2016-02-13 22:30:02
【问题描述】:
我想首先说我是一个完整的 C++ 新手。我不知道任何与之相关的词汇,所以如果这个问题是微不足道的,我很抱歉,因为我现在没有正确的术语或短语来自己搜索解决方案。
目前正在使用我在 github 上找到的这段代码来从我的 3ds 中捕获游戏玩法。 https://github.com/Gotos/Cute3DSCapture/blob/master/main.cpp
我正在尝试添加旋转图像并将其保存到 png 文件的功能。
来自main.cpp 第 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 这只会生成原始图像的副本,而不是修改后的版本。有关详细信息,请参阅下面的答案。