Merge pull request #7951 from jdgleaver/rgui-ps2-colour-fix

(RGUI) Fix background + border colours for PS2
This commit is contained in:
Twinaphex 2019-01-09 21:26:14 +01:00 committed by GitHub
commit 9231998aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -417,11 +417,32 @@ static uint16_t *rgui_framebuf_data = NULL;
static uint16_t argb32_to_abgr1555(uint32_t col)
{
unsigned a = ((col >> 24) & 0xff) >> 7;
unsigned r = ((col >> 16) & 0xff) >> 3;
unsigned g = ((col >> 8) & 0xff) >> 3;
unsigned b = ((col & 0xff) ) >> 3;
return (a << 15) | (b << 10) | (g << 5) | r;
/* Extract colour components */
unsigned a = (col >> 24) & 0xff;
unsigned r = (col >> 16) & 0xff;
unsigned g = (col >> 8) & 0xff;
unsigned b = col & 0xff;
/* Background and border colours are normally semi-transparent
* (so we can see suspended content when opening the quick menu).
* When no content is loaded, the 'image' behind the RGUI background
* and border is black - which has the effect of darkening the
* perceived background/border colours. All the preset theme (and
* default 'custom') colour values have been adjusted to account for
* this, but abgr1555 only has a 1 bit alpha channel. This means all
* colours become fully opaque, and consequently backgrounds/borders
* become abnormally bright.
* We therefore have to darken each RGB value according to the alpha
* component of the input colour... */
float a_factor = (float)a * (1.0 / 255.0);
r = (unsigned)(((float)r * a_factor) + 0.5) & 0xff;
g = (unsigned)(((float)g * a_factor) + 0.5) & 0xff;
b = (unsigned)(((float)b * a_factor) + 0.5) & 0xff;
/* Convert from 8 bit to 5 bit */
r = r >> 3;
g = g >> 3;
b = b >> 3;
/* Return final value - alpha always set to 1 */
return (1 << 15) | (b << 10) | (g << 5) | r;
}
#define argb32_to_pixel_platform_format(color) argb32_to_abgr1555(color)