19 lines
458 B
C++
19 lines
458 B
C++
#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);
|
|
}
|
|
};
|