From a65278c7bc9c0dbca8a74db09fd0aebf1c26ef28 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sat, 29 Feb 2020 16:12:26 +0100 Subject: 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/colour.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'plugingui/colour.h') diff --git a/plugingui/colour.h b/plugingui/colour.h index 3a135fc..0bc8659 100644 --- a/plugingui/colour.h +++ b/plugingui/colour.h @@ -32,7 +32,8 @@ namespace GUI { -class Colour { +class Colour +{ public: Colour(); Colour(float grey, float alpha = 1.0f); @@ -45,13 +46,16 @@ public: bool operator==(const Colour& other) const; bool operator!=(const Colour& other) const; - inline float red() const { return data[0]; } - inline float green() const { return data[1]; } - inline float blue() const { return data[2]; } - inline float alpha() const { return data[3]; } + inline std::uint8_t red() const { return pixel[0]; } + inline std::uint8_t green() const { return pixel[1]; } + inline std::uint8_t blue() const { return pixel[2]; } + inline std::uint8_t alpha() const { return pixel[3]; } + + std::uint8_t* data() { return pixel.data(); } + const std::uint8_t* data() const { return pixel.data(); } private: - std::array data; + std::array pixel{{255, 255, 255, 255}}; }; } // GUI:: -- cgit v1.2.3