private final int blend_color_alpha(int p1, int p2, int a2) {
      // scale alpha by alpha of incoming pixel
      a2 = (a2 * (p2 >>> 24)) >> 8;

      int a1 = a2 ^ 0xff;
      int r = (a1 * ((p1 >> 16) & 0xff) + a2 * ((p2 >> 16) & 0xff)) & 0xff00;
      int g = (a1 * ((p1 >>  8) & 0xff) + a2 * ((p2 >>  8) & 0xff)) & 0xff00;
      int b = (a1 * ( p1        & 0xff) + a2 * ( p2        & 0xff)) >> 8;

      return 0xff000000 | (r << 8) | g | b;
    }