X-Git-Url: https://git.ti.com/gitweb?p=android%2Fexternal-libkmsxx.git;a=blobdiff_plain;f=libkmstest%2Fcolor.cpp;h=78012ac845adde3428d6e033f6407338c5b40e7c;hp=b5b90019646b6b244bf5b70e1c5495cae8acecc0;hb=887fb3bf2bf6496687fcb53f95092690dae90855;hpb=093b77fc295d1bc4694b32fed95da0fab78c4097 diff --git a/libkmstest/color.cpp b/libkmstest/color.cpp index b5b9001..78012ac 100644 --- a/libkmstest/color.cpp +++ b/libkmstest/color.cpp @@ -4,7 +4,8 @@ namespace kms { RGB::RGB() { - r = g = b = a = 0; + r = g = b = 0; + a = 255; } RGB::RGB(uint8_t r, uint8_t g, uint8_t b) @@ -12,15 +13,22 @@ RGB::RGB(uint8_t r, uint8_t g, uint8_t b) this->r = r; this->g = g; this->b = b; - this->a = 0; + this->a = 255; +} + +uint32_t RGB::rgb888() const +{ + return (a << 24) | (r << 16) | (g << 8) | (b << 0); +} + +uint32_t RGB::bgr888() const +{ + return (a << 24) | (b << 16) | (g << 8) | (r << 0); } uint16_t RGB::rgb565() const { - uint16_t r = (this->r >> 3) << 11; - uint16_t g = (this->g >> 2) << 5; - uint16_t b = (this->b >> 3) << 0; - return r | g | b; + return ((r >> 3) << 11) | ((g >> 2) << 5) | ((b >> 3) << 0); } YUV RGB::yuv() const