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

version» Context lines:

pike.git/src/modules/Image/layers.c:332:      /*** layer helpers ****************************************/      #define COMBINE_METHOD_INT   #define CCUT_METHOD_INT      #define qMAX (1.0/COLORMAX)   #define C2F(Z) (qMAX*(Z))      #ifdef CCUT_METHOD_FLOAT - #define CCUT(Z) (DOUBLE_TO_COLORTYPE(qMAX*Z)) + #define CCUT(Z) ((COLORTYPE)(qMAX*Z))   #else /* CCUT_METHOD_INT */ - #define CCUT(Z) (DOUBLE_TO_COLORTYPE((Z)/COLORMAX)) + #define CCUT(Z) ((COLORTYPE)((Z)/COLORMAX))   #endif      #ifdef COMBINE_METHOD_INT         #define COMBINE_ALPHA_SUM(aS,aL) \    CCUT((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS))   #define COMBINE_ALPHA_SUM_V(aS,aL,V) \    COMBINE_ALPHA_SUM(aS,(aL)*(V))   
pike.git/src/modules/Image/layers.c:375:   #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(((int)(P))*(A)) - #define COMBINE_A(P,A) (DOUBLE_TO_COLORTYPE((P)*(A))) + #define COMBINE_A(P,A) ((COLORTYPE)((P)*(A)))   #define COMBINE_V(P,V,A) CCUT((V)*(P)*(A))    - #define F2C(Z) (DOUBLE_TO_COLORTYPE(COLORMAX*(Z))) + #define F2C(Z) ((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 \    (D)->C=COMBINE_ALPHA((S)->C,(L)->C,(SA)->C,(LA)->C), \    (DA)->C=COMBINE_ALPHA_SUM((SA)->C,(LA)->C);      #define ALPHA_ADD_V_NOLA(L,S,D,SA,DA,V,C) \
pike.git/src/modules/Image/layers.c:1615:   #define LM_FUNC lm_negdivide   #define L_TRUNC(X) MINIMUM(255,(X))   #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_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) ((A)%((B)?(B):1))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define L_USE_SA      #define LM_FUNC lm_invsubtract   #define L_TRUNC(X) MAXIMUM(0,(X))
pike.git/src/modules/Image/layers.c:1641:      #define LM_FUNC lm_invdivide   #define L_TRUNC(X) MINIMUM(255,(X))   #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_TRUNC(X) ((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( (int)((A)/C2F(COLORMAX+1-(int)(B))), COLORMAX)   #include "layer_oper.h"
pike.git/src/modules/Image/layers.c:1675:   #define L_TRUNC(X) MINIMUM(255,(X))   #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_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) abs((A)-(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_max - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) MAXIMUM((A),(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_min - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) MINIMUM((A),(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_bitwise_and - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) ((A)&(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_bitwise_or - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) ((A)|(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_bitwise_xor - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) ((A)^(B))   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #undef L_COPY_ALPHA      #define LM_FUNC lm_equal - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)==(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_not_equal - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)!=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_less - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)>(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_more - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)<(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_less_or_equal - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)>=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      #define LM_FUNC lm_more_or_equal - #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X)) + #define L_TRUNC(X) ((COLORTYPE)(X))   #define L_OPER(A,B) (((A)<=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC   #undef L_TRUNC   #undef L_OPER      /* logic functions */      #define L_LOGIC(A,B,C) (((A)&&(B)&&(C))?white:black)   #define LM_FUNC lm_logic_equal
pike.git/src/modules/Image/layers.c:2307:    da->r=CCUT(sa->r*(int)(COLORMAX-la->r));    da->g=CCUT(sa->g*(int)(COLORMAX-la->g));    da->b=CCUT(sa->b*(int)(COLORMAX-la->b));       la++; sa++; da++;    }    else    if (!la) /* full opaque */    {    rgb_group a; -  a.r=a.g=a.b=COLORMAX-DOUBLE_TO_COLORTYPE(alpha*COLORMAX); +  a.r=a.g=a.b=COLORMAX-(COLORTYPE)(alpha*COLORMAX);    smear_color(da,a,len);    }    else    while (len--)    {    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++;
pike.git/src/modules/Image/layers.c:2400:    {    double alpha=ly->alpha_value;    while (len--)    {    if ((s->r==COLORMAX &&    s->g==COLORMAX &&    s->b==COLORMAX)    || !l)    {    *d=*s; -  da->r=MINIMUM(sa->r+DOUBLE_TO_COLORTYPE(alpha*la->r),COLORMAX); -  da->g=MINIMUM(sa->g+DOUBLE_TO_COLORTYPE(alpha*la->g),COLORMAX); -  da->b=MINIMUM(sa->b+DOUBLE_TO_COLORTYPE(alpha*la->b),COLORMAX); +  da->r=MINIMUM(sa->r+(COLORTYPE)(alpha*la->r),COLORMAX); +  da->g=MINIMUM(sa->g+(COLORTYPE)(alpha*la->g),COLORMAX); +  da->b=MINIMUM(sa->b+(COLORTYPE)(alpha*la->b),COLORMAX);    }    else    { -  d->r=s->r+DOUBLE_TO_COLORTYPE(alpha*l->r); -  d->g=s->g+DOUBLE_TO_COLORTYPE(alpha*l->g); -  d->b=s->b+DOUBLE_TO_COLORTYPE(alpha*l->b); +  d->r=s->r+(COLORTYPE)(alpha*l->r); +  d->g=s->g+(COLORTYPE)(alpha*l->g); +  d->b=s->b+(COLORTYPE)(alpha*l->b);    -  da->r=MINIMUM(sa->r+DOUBLE_TO_COLORTYPE(alpha*l->r),COLORMAX); -  da->g=MINIMUM(sa->g+DOUBLE_TO_COLORTYPE(alpha*l->g),COLORMAX); -  da->b=MINIMUM(sa->b+DOUBLE_TO_COLORTYPE(alpha*l->b),COLORMAX); +  da->r=MINIMUM(sa->r+(COLORTYPE)(alpha*l->r),COLORMAX); +  da->g=MINIMUM(sa->g+(COLORTYPE)(alpha*l->g),COLORMAX); +  da->b=MINIMUM(sa->b+(COLORTYPE)(alpha*l->b),COLORMAX);    }    da++; sa++; la++; s++; d++;    }    }   }      /*** the add-layer function ***************************/      static inline void img_lay_first_line(struct layer *l,    int xoffs,int xsize,