Convert RGB to ARGB in Android

I have an RGB code for color. For example, gray color (118,118,118). How can I use it in setPixel () function? Because the setPixel () function wants argb to be for color.

+4
source share
2 answers
int color = Color.argb(255, 118, 118, 188); 

if full opacity is required.

+12
source

The first (a) value represents an alpha channel or simple language: transparency. (How much you can see through this color, the images behind it)

The value is one byte, so valid values ​​range from 0 to 255.

According to the answer above, a value of 255 means that your color will be completely opaque (solid).
A value of 128 will give you 50% transparency.
A value of 0 will make your object completely invisible regardless of your color value, but the object still exists as a sheet of crystal clear glass, if you allow an analogy.

This can be useful, for example, for secret / hidden / invisible buttons, creating Easter eggs, or for specific cases of customizing the user interface.

+3
source

Source: https://habr.com/ru/post/1484661/


All Articles