missing namespace

This commit is contained in:
John Sennesael 2021-02-26 11:13:15 -06:00
parent cd128ec9dc
commit 8248c44538
1 changed files with 6 additions and 8 deletions

View File

@ -514,8 +514,8 @@ using Bitmap = std::vector<Color>;
struct Image
{
uint32_t width{0};
uint32_t height{0};
std::uint32_t width{0};
std::uint32_t height{0};
Bitmap bitmap;
};
@ -643,7 +643,7 @@ std::vector<char> toMask(const Image& image, const Color& alpha)
return result;
}
char percentMatch(const std::vector<char>& a, const std::vector<char>& b)
float percentMatch(const std::vector<char>& a, const std::vector<char>& b)
{
std::uint32_t matches{0};
std::uint32_t i{0};
@ -652,19 +652,17 @@ char percentMatch(const std::vector<char>& a, const std::vector<char>& b)
if (c == b[i]) matches++;
i++;
}
return static_cast<char>(
(static_cast<float>(matches) / static_cast<float>(a.size()) ) * 100.0f
);
return (static_cast<float>(matches) / static_cast<float>(a.size())) * 100.0f;
}
std::string findMatch(const Image& image, const Color& alpha)
{
const auto imageMask = toMask(image, alpha);
char maxPercent{0};
float maxPercent{0.0f};
std::string result;
for (const auto ctb: charToBitmap)
{
const char pm = percentMatch(imageMask, ctb.second);
const float pm = percentMatch(imageMask, ctb.second);
if (pm > maxPercent)
{
result = ctb.first;