抽象多媒体类, 修复gtest问题
This commit is contained in:
18
include/imageService.h
Normal file
18
include/imageService.h
Normal 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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user