5e39651999-04-22Mirar (Pontus Hagland) /* template for operator layer row function */
54e0781999-04-24Mirar (Pontus Hagland) static void LM_FUNC(rgb_group *s,rgb_group *l,rgb_group *d, rgb_group *sa,rgb_group *la,rgb_group *da, int len,double alpha) {
7383191999-06-21Mirar (Pontus Hagland) #ifndef L_LOGIC
54e0781999-04-24Mirar (Pontus Hagland)  if (alpha==0.0) {
502f1e1999-08-12Per Hedbor #ifdef LAYER_DUAL
54e0781999-04-24Mirar (Pontus Hagland)  MEMCPY(d,s,sizeof(rgb_group)*len); MEMCPY(da,sa,sizeof(rgb_group)*len);
502f1e1999-08-12Per Hedbor #endif
54e0781999-04-24Mirar (Pontus Hagland)  return; } else if (alpha==1.0) { if (!la) /* no layer alpha => full opaque */ while (len--) { d->r=L_TRUNC(L_OPER(s->r,l->r)); d->g=L_TRUNC(L_OPER(s->g,l->g)); d->b=L_TRUNC(L_OPER(s->b,l->b)); *da=white; l++; s++; sa++; da++; d++; } else while (len--) { if (la->r==COLORMAX && la->g==COLORMAX && la->b==COLORMAX) { d->r=L_TRUNC(L_OPER(s->r,l->r)); d->g=L_TRUNC(L_OPER(s->g,l->g)); d->b=L_TRUNC(L_OPER(s->b,l->b)); #ifdef L_USE_SA *da=*sa;
7383191999-06-21Mirar (Pontus Hagland) #else *da=white;
54e0781999-04-24Mirar (Pontus Hagland) #endif } else if (la->r==0 && la->g==0 && la->b==0) { *d=*s; *da=*sa; } else { d->r=L_TRUNC(L_OPER(s->r,l->r)); ALPHA_ADD(s,d,d,sa,la,da,r); d->g=L_TRUNC(L_OPER(s->g,l->g)); ALPHA_ADD(s,d,d,sa,la,da,g); d->b=L_TRUNC(L_OPER(s->b,l->b)); ALPHA_ADD(s,d,d,sa,la,da,b); #ifdef L_USE_SA *da=*sa; #endif } l++; s++; la++; sa++; da++; d++; } } else { if (!la) /* no layer alpha => full opaque */ while (len--) { d->r=L_TRUNC(L_OPER(s->r,l->r)); ALPHA_ADD_V_NOLA(s,d,d,sa,da,alpha,r); d->g=L_TRUNC(L_OPER(s->g,l->g)); ALPHA_ADD_V_NOLA(s,d,d,sa,da,alpha,g); d->b=L_TRUNC(L_OPER(s->b,l->b)); ALPHA_ADD_V_NOLA(s,d,d,sa,da,alpha,b); #ifdef L_USE_SA *da=*sa; #endif l++; s++; sa++; da++; d++; } else while (len--) { d->r=L_TRUNC(L_OPER(s->r,l->r)); ALPHA_ADD_V(s,d,d,sa,la,da,alpha,r); d->g=L_TRUNC(L_OPER(s->g,l->g)); ALPHA_ADD_V(s,d,d,sa,la,da,alpha,g); d->b=L_TRUNC(L_OPER(s->b,l->b)); ALPHA_ADD_V(s,d,d,sa,la,da,alpha,b); #ifdef L_USE_SA *da=*sa; #endif l++; s++; la++; sa++; da++; d++; } }
7383191999-06-21Mirar (Pontus Hagland) #else /* L_LOGIC */
5e39651999-04-22Mirar (Pontus Hagland)  if (alpha==0.0) {
7383191999-06-21Mirar (Pontus Hagland)  smear_color(d,L_TRANS,len); smear_color(da,L_TRANS,len);
5e39651999-04-22Mirar (Pontus Hagland)  return; }
7383191999-06-21Mirar (Pontus Hagland)  else
5e39651999-04-22Mirar (Pontus Hagland)  { if (!la) /* no layer alpha => full opaque */ while (len--) {
7383191999-06-21Mirar (Pontus Hagland)  *da=*d=L_LOGIC(L_OPER(s->r,l->r), L_OPER(s->g,l->g), L_OPER(s->b,l->b));
5e39651999-04-22Mirar (Pontus Hagland)  l++; s++; sa++; da++; d++; } else while (len--) {
7383191999-06-21Mirar (Pontus Hagland)  if (la->r==0 && la->g==0 && la->b==0) *d=*da=L_TRANS; else *da=*d=L_LOGIC(L_OPER(s->r,l->r), L_OPER(s->g,l->g), L_OPER(s->b,l->b));
5e39651999-04-22Mirar (Pontus Hagland)  l++; s++; la++; sa++; da++; d++; } }
7383191999-06-21Mirar (Pontus Hagland) #endif /* L_LOGIC */
5e39651999-04-22Mirar (Pontus Hagland) }
54e0781999-04-24Mirar (Pontus Hagland)