From 15e9d38d36573ba0e1ec6e0cc2768b12ca01bff0 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Feb 2020 16:12:26 +0100 Subject: WIP: 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. --- plugingui/font.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'plugingui/font.cc') 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; -- cgit v1.2.3