抽象多媒体类, 修复gtest问题

This commit is contained in:
Jie
2024-09-09 13:20:59 +08:00
parent 628b95d37d
commit 7c049db4ac
10 changed files with 166 additions and 31 deletions

18
include/imageService.h Normal file
View File

@@ -0,0 +1,18 @@
#include <SFML/Graphics.hpp>
#include <algorithm>
class ImageService {
private:
sf::Texture texture;
public:
ImageService(const std::string& name){
texture.loadFromFile(name);
}
sf::Texture& GetTexture(){
return texture;
}
float GetScale(int width, int height){
auto imgSize = texture.getSize();
return std::min(static_cast<float>(width) / imgSize.x, static_cast<float>(height) / imgSize.y);
}
};