-1

Given two colors A and B, I would like to get the resulting color C, that is the most possible realistic natural mix of the A and B.

Example :

Red + Yellow = Orange 
Blue + Yellow = Green
Red + Blue = Purple
Blue + White = Light Blue
Blue + Black = Dark Blue 

etc...

Can I get it with ARGB representation of the given colors?

Nameless
  • 259
  • 2
  • 4
  • 15

1 Answers1

-1

We can call a function which returns result array when give two arrays as parameters. But Arrays should be same sizes.

public int getAvgARGB(int[] clr1, int[] clr2){
    int[] returnArray = new int[clr1.length];
    for(int i=0; i<clr1.length;i++){
       int a1[i] = (clr1[i] & 0xFF000000) >>> 24;
       int r1[i] = (clr1[i] & 0x00FF0000) >> 16;
       int g1[i] = (clr1[i] & 0x0000FF00) >> 8;
       int b1[i] = (clr1[i] & 0x000000FF) ;

       int a2[i] = (clr2[i] & 0xFF000000) >>> 24;
       int r2[i] = (clr2[i] & 0x00FF0000) >> 16;
       int g2[i] = (clr2[i] & 0x0000FF00) >> 8;
       int b2[i] = (clr2[i] & 0x000000FF) ;

       int aAvg = (a1[i] + a2[i]) / 2;
       int rAvg = (r1[i] + r2[i]) / 2;
       int gAvg = (g1[i] + g2[i]) / 2;
       int bAvg = (b1[i] + b2[i]) / 2;

       int returnArray[i] = (aAvg << 24) + (rAvg << 16) + (gAvg << 8) + bAvg; 

     }
       return returnArray;
}
  • Thank you. But...how should I use it? How should I fill clr1 and clr2 arrays parameters? And what will contain the result array? – Nameless Jan 08 '16 at 14:13