pike.git / src / modules / Image / layers.c

version» Context lines:

pike.git/src/modules/Image/layers.c:341:   #ifdef CCUT_METHOD_FLOAT   #define CCUT(Z) (DOUBLE_TO_COLORTYPE(qMAX*Z))   #else /* CCUT_METHOD_INT */   #define CCUT(Z) (DOUBLE_TO_COLORTYPE((Z)/COLORMAX))   #endif      #ifdef COMBINE_METHOD_INT         #define COMBINE_ALPHA_SUM(aS,aL) \ -  CCUT((COLORMAX*DOUBLE_TO_INT(aL))+(COLORMAX-DOUBLE_TO_INT(aL))*(aS)) +  CCUT((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS))   #define COMBINE_ALPHA_SUM_V(aS,aL,V) \    COMBINE_ALPHA_SUM(aS,(aL)*(V))      #define COMBINE_ALPHA(S,L,aS,aL) \ -  ( (COLORTYPE)((((S)*(DOUBLE_TO_INT(COLORMAX-(aL)))*(aS))+ \ -  ((L)*(DOUBLE_TO_INT(aL))*COLORMAX))/ \ -  (((COLORMAX*DOUBLE_TO_INT(aL))+(COLORMAX-DOUBLE_TO_INT(aL))*(aS))) ) ) +  ( (COLORTYPE)((((S)*((int)(COLORMAX-(aL)))*(aS))+ \ +  ((L)*((int)(aL))*COLORMAX))/ \ +  (((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS))) ) )      #define COMBINE_ALPHA_V(S,L,aS,aL,V) \    COMBINE_ALPHA((S),(L),(aS),((aL)*(V)))      #else   #ifdef COMBINE_METHOD_FLOAT      #define COMBINE_ALPHA(S,L,aS,aL) \    ( (COLORTYPE)( ( (S)*(1.0-C2F(aL))*C2F(aS) + (L)*C2F(aL) ) / \    ( (C2F(aL)+(1-C2F(aL))*C2F(aS))) ) )
pike.git/src/modules/Image/layers.c:374:    ((COLORTYPE)(COLORMAX*(C2F(aL)+(1.0-C2F(aL))*C2F(aS))))   #define COMBINE_ALPHA_SUM_V(aS,aL,V) \    COMBINE_ALPHA_SUM(aS,(aL)*(V))      #else /* unknown COMBINE_METHOD */   #error unknown COMBINE_METHOD   #endif /* COMBINE_METHOD_FLOAT */      #endif    - #define COMBINE(P,A) CCUT((DOUBLE_TO_INT(P))*(A)) + #define COMBINE(P,A) CCUT(((int)(P))*(A))   #define COMBINE_A(P,A) (DOUBLE_TO_COLORTYPE((P)*(A)))   #define COMBINE_V(P,V,A) CCUT((V)*(P)*(A))      #define F2C(Z) (DOUBLE_TO_COLORTYPE(COLORMAX*(Z)))      #define ALPHA_ADD(S,L,D,SA,LA,DA,C) \    if (!(LA)->C) (D)->C=(S)->C,(DA)->C=(SA)->C; \    else if (!(SA)->C) (D)->C=(L)->C,(DA)->C=(LA)->C; \    else if ((LA)->C==COLORMAX) (D)->C=(L)->C,(DA)->C=(LA)->C; \    else \
pike.git/src/modules/Image/layers.c:508:    colorp->r=colorp->g=colorp->b=F2C(v);    return;    }      #define i floor(h)   #define f (h-i)   #define p F2C(v * (1 - s))   #define q F2C(v * (1 - (s * f)))   #define t F2C(v * (1 - (s * (1 -f))))   #define V F2C(v) -  switch(DOUBLE_TO_INT(i)) +  switch((int)(i))    {    case 6:    case 0: colorp->r = V; colorp->g = t; colorp->b = p; break;    case 7:    case 1: colorp->r = q; colorp->g = V; colorp->b = p; break;    case 2: colorp->r = p; colorp->g = V; colorp->b = t; break;    case 3: colorp->r = p; colorp->g = q; colorp->b = V; break;    case 4: colorp->r = t; colorp->g = p; colorp->b = V; break;    case 5: colorp->r = V; colorp->g = p; colorp->b = q; break;    default: Pike_fatal("unhandled case\n");
pike.git/src/modules/Image/layers.c:1599:   #define LM_FUNC lm_multiply   #define L_TRUNC(X) (X)   #define L_OPER(A,B) CCUT((A)*(int)(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_divide   #define L_TRUNC(X) MINIMUM(255,(X)) - #define L_OPER(A,B) MINIMUM( DOUBLE_TO_INT((A)/C2F(1+(int)(B))), COLORMAX) + #define L_OPER(A,B) MINIMUM( (int)((A)/C2F(1+(int)(B))), COLORMAX)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_negdivide   #define L_TRUNC(X) MINIMUM(255,(X)) - #define L_OPER(A,B) 1.0-MINIMUM( DOUBLE_TO_INT((A)/C2F(1+(int)(B))), COLORMAX) + #define L_OPER(A,B) 1.0-MINIMUM( (int)((A)/C2F(1+(int)(B))), COLORMAX)      #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_modulo   #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((A)%((B)?(B):1))   #include "layer_oper.h"
pike.git/src/modules/Image/layers.c:1634:   #define LM_FUNC lm_invsubtract   #define L_TRUNC(X) MAXIMUM(0,(X))   #define L_OPER(A,B) ((B)-(int)(A))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_invdivide   #define L_TRUNC(X) MINIMUM(255,(X)) - #define L_OPER(A,B) MINIMUM( DOUBLE_TO_INT((B)/C2F(1+(int)(A))), COLORMAX) + #define L_OPER(A,B) MINIMUM( (int)((B)/C2F(1+(int)(A))), COLORMAX)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_invmodulo   #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((B)%((A)?(A):1))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_idivide   #define L_TRUNC(X) MINIMUM(255,(X)) - #define L_OPER(A,B) MINIMUM( DOUBLE_TO_INT((A)/C2F(COLORMAX+1-(int)(B))), COLORMAX) + #define L_OPER(A,B) MINIMUM( (int)((A)/C2F(COLORMAX+1-(int)(B))), COLORMAX)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_imultiply   #define L_TRUNC(X) (X)   #define L_OPER(A,B) CCUT((A)*(COLORMAX-(int)(B)))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_invidivide   #define L_TRUNC(X) MINIMUM(255,(X)) - #define L_OPER(A,B) MINIMUM( DOUBLE_TO_INT((B)/C2F(COLORMAX+1-(int)(A))), COLORMAX) + #define L_OPER(A,B) MINIMUM( (int)((B)/C2F(COLORMAX+1-(int)(A))), COLORMAX)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #undef L_USE_SA      #define LM_FUNC lm_difference   #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) abs((A)-(B))
pike.git/src/modules/Image/layers.c:2184:    if (my_rand(255*255) <    (unsigned)(la->r*87 + la->g*127 + la->b*41))    *d=*l,*da=white;    else    *d=*s,*da=*sa;    l++; s++; la++; sa++; da++; d++;    }    }    else    { -  int v = DOUBLE_TO_INT(COLORMAX*alpha); +  int v = (int)(COLORMAX*alpha);    if (!la) /* no layer alpha => full opaque */    while (len--)    {    if (my_rand(256) < (unsigned)v)    *d=*l,*da=white;    else    *d=*s,*da=*sa;    l++; s++; sa++; da++; d++;    }    else
pike.git/src/modules/Image/layers.c:2313:    else    if (!la) /* full opaque */    {    rgb_group a;    a.r=a.g=a.b=COLORMAX-DOUBLE_TO_COLORTYPE(alpha*COLORMAX);    smear_color(da,a,len);    }    else    while (len--)    { -  da->r=CCUT(sa->r*DOUBLE_TO_INT(COLORMAX-alpha*la->r)); -  da->g=CCUT(sa->g*DOUBLE_TO_INT(COLORMAX-alpha*la->g)); -  da->b=CCUT(sa->b*DOUBLE_TO_INT(COLORMAX-alpha*la->b)); +  da->r=CCUT(sa->r*(int)(COLORMAX-alpha*la->r)); +  da->g=CCUT(sa->g*(int)(COLORMAX-alpha*la->g)); +  da->b=CCUT(sa->b*(int)(COLORMAX-alpha*la->b));       la++; sa++; da++;    }   }      static void lm_spec_burn_alpha(struct layer *ly,    rgb_group *l, rgb_group *la,    rgb_group *s, rgb_group *sa,    rgb_group *d, rgb_group *da,    int len)