如何将 Alpha、Red、Green、Blue 的 4 个单独的 Int 值更改为 TYPE_INT_RGB?

Max*_*hez 2 java image bufferedreader

感谢您的时间 :)。我已经查看了 TYPE_INT_RGB 和 TYPE_INT_ARGB 的格式,现在知道如何将这个 TYPE_INT_RGB 转换为 4 个单独的值,但是如果我要对每个值进行修改(比如每个添加 20,所以 Alpha+=20,red+=20 ,等等)我将如何将这些值重新组合成这种 TYPE_INT_RGB 格式?谢谢!

mP.*_*mP. 5

// to extract the components into individual ints.
int argb = something();
int red = 0xFF & ( argb >> 16);
int alpha = 0xFF & (argb >> 24);
int blue = 0xFF & (argb >> 0 );
int green = 0xFF & (argb >> 8 );

// to recreate the argb
int argb = (alpha << 24) | (red << 16 ) | (green<<8) | blue;
Run Code Online (Sandbox Code Playgroud)