summaryrefslogtreecommitdiff
path: root/plugingui/font.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2020-02-29 16:12:26 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2020-03-07 19:22:34 +0100
commita65278c7bc9c0dbca8a74db09fd0aebf1c26ef28 (patch)
treef6137641afd154dca1c45480137e9b56afb1a7d6 /plugingui/font.cc
parent450e39c5b02ace3c50d116e4cba825ff695c8665 (diff)
Read images as uint8_t instead of float. Convert Colour and all colour related operations to use uint8_t instade of float and finally optimize rendering to render lines instead of single pixels.
Diffstat (limited to 'plugingui/font.cc')
-rw-r--r--plugingui/font.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/plugingui/font.cc b/plugingui/font.cc
index 9f54b16..0500e81 100644
--- a/plugingui/font.cc
+++ b/plugingui/font.cc
@@ -59,8 +59,8 @@ Font::Font(const std::string& fontfile)
auto& pixel = img_font.getPixel(px, 0);
// Find next purple pixel in top row:
- if((pixel.red() == 1.0f) && (pixel.green() == 0.0f) &&
- (pixel.blue() == 1.0f) && (pixel.alpha() == 1.0f))
+ if((pixel.red() == 255) && (pixel.green() == 0) &&
+ (pixel.blue() == 255) && (pixel.alpha() == 255))
{
break;
}
@@ -124,9 +124,7 @@ PixelBufferAlpha *Font::render(const std::string& text) const
for(size_t y = 0; y < img_font.height(); ++y)
{
auto& c = img_font.getPixel(x + character.offset, y);
- pb->setPixel(x + x_offset + character.pre_bias, y,
- c.red() * 255, c.green() * 255,
- c.blue() * 255, c.alpha() * 255);
+ pb->setPixel(x + x_offset + character.pre_bias, y, c);
}
}
x_offset += character.width + spacing + character.post_bias;