简体   繁体   中英

Convert RGBA to just RGB but retain color in C#

The below color is rgba(55, 103, 235, 0.53) on a white background. However is there code in c#/.NET that convert that to the actual rgb without opacity but retain the same color. The rgba is actually rgb(149, 174, 244) when I hover over it with a color picker.

在此处输入图像描述

I'm not sure if this works on any background color, but for your example, you can calucate the values like this:

value = backgroundValue - (backgroundValue - colorValue) * alphaValue
-----
r = 255 - (255 - 55)  * 0.53  = 149
g = 255 - (255 - 103) * 0.53 ~= 174
b = 255 - (255 - 235) * 0.53 ~= 244

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM