//If da=0 (fully opaque), then alpha blending formula is simpler:
//result_color = dc*sa + sc*(1 - sa)
//result_alpha = 0
static INLINE
void ablend(int dr,int dg,int db, int *sr,int *sg,int *sb,int sa) {
  uint32_t *st = ab_lut[255-sa];
  uint32_t *dt = ab_lut[sa];
  *sr = iglut[int2cfp(st[*sr]+dt[dr])];
  *sg = iglut[int2cfp(st[*sg]+dt[dg])];
  *sb = iglut[int2cfp(st[*sb]+dt[db])];
}

//full alpha blending with gamma correction
//result_color = (dc*(sa - ra) + sc*(255 - sa))/(255 - ra)
//result_alpha = ra
//where ra=da*sa, da=dst_alpha, sa=src_alpha, dc=dst_color, sc=src_color
static INLINE 
void fablend(int dr,int dg,int db,int da, int *sr,int *sg,int *sb,int *sa) {
  int ra = (da * *sa)>>8;
  uint32_t d = ridiv_lut[ra];
  uint32_t *st = fab_lut[255 - *sa];
  uint32_t *dt = fab_lut[*sa - ra];
  *sr = iglut[int2cfp((dt[dr] + st[*sr])*d)];
  *sg = iglut[int2cfp((dt[dg] + st[*sg])*d)];
  *sb = iglut[int2cfp((dt[db] + st[*sb])*d)];
  *sa = ra;
}