def decompose_alpha_component(channel, color, mask, bg)
      cc, mc, bc = send(channel, color), send(channel, mask), send(channel, bg)

      return 0x00 if bc == cc
      return 0xff if bc == mc
      return 0xff if cc == mc

      (((bc - cc).to_f / (bc - mc).to_f) * MAX).round
    end
def decompose_alpha_component(channel, color, mask, bg)
      cc, mc, bc = send(channel, color), send(channel, mask), send(channel, bg)

      return 0x00 if bc == cc
      return 0xff if bc == mc
      return 0xff if cc == mc

      (((bc - cc).to_f / (bc - mc).to_f) * MAX).round
    end
Decomposes an alpha channel for either the r, g or b color channel.
 @param [:r, :g, :b] channel The channel to decompose the alpha channel
   from.
 @param [Integer] color The color that was the result of compositing.
 @param [Integer] mask The opaque variant of the color that was being
   composed
 @param [Integer] bg The background color on which the color was composed.
 @return [Integer] The decomposed alpha value for the channel.