private static int blend_add_pin(int a, int b) { // setup (this portion will always be the same) int f = (b & ALPHA_MASK) >>> 24; int ar = (a & RED_MASK) >> 16; int ag = (a & GREEN_MASK) >> 8; int ab = (a & BLUE_MASK); int br = (b & RED_MASK) >> 16; int bg = (b & GREEN_MASK) >> 8; int bb = (b & BLUE_MASK); // formula: int cr = ar + br; int cg = ag + bg; int cb = ab + bb; // alpha blend (this portion will always be the same) // (err, NOT quite the same here - this is the "correct" version using "/ 255") return (low(((a & ALPHA_MASK) >>> 24) + f, 0xff) << 24 | (peg(ar + (((cr - ar) * f) / 255)) << 16) | (peg(ag + (((cg - ag) * f) / 255)) << 8) | (peg(ab + (((cb - ab) * f) / 255)) ) ); }