From 3e747d769f63fde60f6095bd1ae7c651d4237f39 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 4 Jun 2016 18:36:00 +0200 Subject: Make Colour movabl;e and make Image contain a vector of Colour instead of raw char data. --- plugingui/font.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'plugingui/font.cc') diff --git a/plugingui/font.cc b/plugingui/font.cc index 4671f86..3be7dd5 100644 --- a/plugingui/font.cc +++ b/plugingui/font.cc @@ -34,7 +34,7 @@ Font::Font(const std::string& fontfile) size_t px = 0; size_t c; - for(c = 0; c < characters.size() && px < img_font.width(); ++c) + for(c = 0; c < (characters.size() - 1) && px < img_font.width(); ++c) { auto& character = characters[c]; character.offset = px + 1; @@ -47,14 +47,13 @@ Font::Font(const std::string& fontfile) ++px; - Colour pixel; while(px < img_font.width()) { - pixel = img_font.getPixel(px, 0); + auto& pixel = img_font.getPixel(px, 0); // Find next purple pixel in top row: - if((pixel.red == 1) && (pixel.green == 0) && - (pixel.blue == 1) && (pixel.alpha == 1)) + if((pixel.red() == 1.0f) && (pixel.green() == 0.0f) && + (pixel.blue() == 1.0f) && (pixel.alpha() == 1.0f)) { break; } @@ -111,9 +110,10 @@ PixelBufferAlpha *Font::render(const std::string& text) const { for(size_t y = 0; y < img_font.height(); ++y) { - Colour c = img_font.getPixel(x + character.offset, 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); + c.red() * 255, c.green() * 255, + c.blue() * 255, c.alpha() * 255); } } x_offset += character.width + spacing + character.post_bias; -- cgit v1.2.3