【发布时间】:2014-10-29 08:54:25
【问题描述】:
我想生成一个字形的位图图像,以便我可以将它与另一个图像中未知字母的像素值进行比较。
我使用的是 Visual Studio 2008,我的项目是 C++,我使用的是 SFML。我可以很好地从 ttf 文件加载字体,我尝试执行以下操作:
sf::Font myFont;
myFont.loadFromFile("Path\\arial.ttf");
sf::Texture myTexture = myFont.getTexture(48);
sf::Image textureImage = myTexture.copyToImage();
sf::Glyph myGlyph = myFont.getGlyph(65, 12, false); // get the 'A' glyph
sf::Image glyphImage;
glyphImage.create(myGlyph.bounds.width, myGlyph.bounds.height, sf::Color::White);
glyphImage.copy(textureImage, 0, 0, myGlyph.textureRect);
我认为这不起作用,因为我只是从字形所在的纹理部分创建图像,而不是字形本身的像素值。
有人可以帮忙吗?
【问题讨论】:
标签: c++ visual-studio-2008 bitmap sfml glyph