Java Array Average average4RGBA(int var0, int var1, int var2, int var3)

Here you can find the source of average4RGBA(int var0, int var1, int var2, int var3)

Description

average RGBA

License

LGPL

Declaration

private static int average4RGBA(int var0, int var1, int var2, int var3) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    private static int average4RGBA(int var0, int var1, int var2, int var3) {
        int var4 = var0 & 255;
        int var5 = var1 & 255;
        int var6 = var2 & 255;
        int var7 = var3 & 255;

        switch (var4 << 24 | var5 << 16 | var6 << 8 | var7) {
        case -16777216:
            return var0;

        case -16776961:
            return average2RGBA(var0, var3);

        case -16711936:
            return average2RGBA(var0, var2);

        case -65536:
            return average2RGBA(var0, var1);

        case -1://from w  ww.  j  a  va 2  s. co m
        case 0:
            return average2RGBA(average2RGBA(var0, var3), average2RGBA(var1, var2));

        case 255:
            return var3;

        case 65280:
            return var2;

        case 65535:
            return average2RGBA(var2, var3);

        case 16711680:
            return var1;

        case 16711935:
            return average2RGBA(var1, var3);

        case 16776960:
            return average2RGBA(var1, var2);

        default:
            int var8 = var4 + var5 + var6 + var7;
            int var9 = var8 >> 2;

            for (int var10 = 8; var10 < 32; var10 += 8) {
                int var11 = (var4 * (var0 >> var10 & 255) + var5 * (var1 >> var10 & 255)
                        + var6 * (var2 >> var10 & 255) + var7 * (var3 >> var10 & 255)) / var8;
                var9 |= var11 << var10;
            }

            return var9;
        }
    }

    private static int average2RGBA(int var0, int var1) {
        return ((var0 & -16843010) >>> 1) + ((var1 & -16843010) >>> 1) | var0 & var1 & 16843009;
    }
}

Related

  1. average(long[] array)
  2. average(long[] vals)
  3. average(Number[] numbers)
  4. average1(double[] d)
  5. average2(double[] d)
  6. averageChroma(float[] chromaSums, int countChromas)
  7. averageLuminance(double[] luminance)
  8. averageNonZeros(int[] array)
  9. averagePt(double[][] ndPoints)