1
    int color1 = 0xDDfbc2ba;
    int color2 = 0xDD7a6c3e;

    int mixColor = mixTwoColors(color1,color2,0.5f);  


public static int mixTwoColors( int color1, int color2, float amount )
{
    final byte ALPHA_CHANNEL = 24;
    final byte RED_CHANNEL   = 16;
    final byte GREEN_CHANNEL =  8;
    final byte BLUE_CHANNEL  =  0;

    final float inverseAmount = 1.0f - amount;

    int a = ((int)(((float)(color1 >> ALPHA_CHANNEL & 0xff )*amount) +
            ((float)(color2 >> ALPHA_CHANNEL & 0xff )*inverseAmount))) & 0xff;
    int r = ((int)(((float)(color1 >> RED_CHANNEL & 0xff )*amount) +
            ((float)(color2 >> RED_CHANNEL & 0xff )*inverseAmount))) & 0xff;
    int g = ((int)(((float)(color1 >> GREEN_CHANNEL & 0xff )*amount) +
            ((float)(color2 >> GREEN_CHANNEL & 0xff )*inverseAmount))) & 0xff;
    int b = ((int)(((float)(color1 & 0xff )*amount) +
            ((float)(color2 & 0xff )*inverseAmount))) & 0xff;

    return a << ALPHA_CHANNEL | r << RED_CHANNEL | g << GREEN_CHANNEL | b << BLUE_CHANNEL;
}

この結果は -574974084 です

次の 2 つの色をブレンドに使用していますが、負の数になるのはなぜですか? また、androidでペイントやporterduffxfermodeを使って下の写真のような明るい口紅のエフェクトを作るにはどうすればいいでしょうか?いくつかの提案をお願いします。どうもありがとうございました。

ここに画像の説明を入力

4

0 に答える 0