def _BackendPremultiplication(color):
 alpha = color[3]
 rgb = color[0:3]
 multiplied = [((x * (alpha + 1)) >> 8) for x in rgb]
 if alpha:
  alpha_inverse = (16777215 / alpha)
  unmultiplied = [((x * alpha_inverse) >> 16) for x in multiplied]
 else:
  unmultiplied = ([0] * 3)
 return tuple((unmultiplied + [alpha]))

def _BackendPremultiplication ( color ) : alpha = color [ 3 ] rgb = color [ 0 : 3 ] multiplied = [ ( ( x * ( alpha + 1 ) ) >> 8 ) for x in rgb ] if alpha : alpha_inverse = ( 16777215 / alpha ) unmultiplied = [ ( ( x * alpha_inverse ) >> 16 ) for x in multiplied ] else : unmultiplied = ( [ 0 ] * 3 ) return tuple ( ( unmultiplied + [ alpha ] ) )
apply premultiplication and unpremultiplication to match production .