mp-sfml/include/imageService.h

19 lines
458 B
C
Raw Normal View History

2024-09-09 13:20:59 +08:00
#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);
}
};