diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-02-07 23:13:47 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-02-07 23:17:06 +0100 |
commit | 887b4a7a1a7d27d6c5bf12024e730fa06b2ab03e (patch) | |
tree | 08f30532b6f16c33ef34b325011162e2b0892bba /SharedGraphics/Color.h | |
parent | 71b9ec1ae00db9206506dca95930db24c989d530 (diff) | |
download | serenity-887b4a7a1a7d27d6c5bf12024e730fa06b2ab03e.zip |
Start working on a simple Launcher app.
Let GButton have an optional icon (GraphicsBitmap) that gets rendered in the
middle of the button if present.
Also add GraphicsBitmap::load_from_file() which allows mmap'ed RGBA32 files.
I wrote a little program to take "raw" files from GIMP and swizzle them into
the correct byte order.
Diffstat (limited to 'SharedGraphics/Color.h')
-rw-r--r-- | SharedGraphics/Color.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/SharedGraphics/Color.h b/SharedGraphics/Color.h index b38ecbb5ab..934e6bdd13 100644 --- a/SharedGraphics/Color.h +++ b/SharedGraphics/Color.h @@ -29,9 +29,20 @@ public: Color(byte r, byte g, byte b) : m_value((r << 16) | (g << 8) | b) { } Color(RGBA32 rgba) : m_value(rgba) { } - int red() const { return (m_value >> 16) & 0xff; } - int green() const { return (m_value >> 8) & 0xff; } - int blue() const { return m_value & 0xff; } + byte red() const { return (m_value >> 16) & 0xff; } + byte green() const { return (m_value >> 8) & 0xff; } + byte blue() const { return m_value & 0xff; } + byte alpha() const { return (m_value >> 24) & 0xff; } + + Color blend(Color source) const + { + RGBA32 redblue1 = ((0x100u - source.alpha()) * (m_value & 0xff00ff)) >> 8; + RGBA32 redblue2 = (source.alpha() * (source.m_value & 0xff00ff)) >> 8; + RGBA32 green1 = ((0x100u - source.alpha()) * (m_value & 0x00ff00)) >> 8; + RGBA32 green2 = (source.alpha() * (source.m_value & 0x00ff00)) >> 8; + return Color(((redblue1 | redblue2) & 0xff00ff) + ((green1 | green2) & 0x00ff00)); + } + RGBA32 value() const { return m_value; } |