Branch: Tag:

2000-08-05

2000-08-05 23:47:27 by Henrik Grubbström (Grubba) <grubba@grubba.org>

More 64bit fixes.

Rev: src/modules/Image/image.h:1.38
Rev: src/modules/Image/layers.c:1.47

1:   /*   **! module Image   **! note - **! $Id: layers.c,v 1.46 2000/08/05 11:07:31 grubba Exp $ + **! $Id: layers.c,v 1.47 2000/08/05 23:47:27 grubba Exp $   **! class Layer   **! see also: layers   **!
215:      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.46 2000/08/05 11:07:31 grubba Exp $"); + RCSID("$Id: layers.c,v 1.47 2000/08/05 23:47:27 grubba Exp $");      #include "image_machine.h"   
494:   #define C2F(Z) (qMAX*(Z))      #ifdef CCUT_METHOD_FLOAT - #define CCUT(Z) ((COLORTYPE)(qMAX*Z)) + #define CCUT(Z) (DOUBLE_TO_COLORTYPE(qMAX*Z))   #else /* CCUT_METHOD_INT */ - #define CCUT(Z) ((COLORTYPE)((Z)/COLORMAX)) + #define CCUT(Z) (DOUBLE_TO_COLORTYPE((Z)/COLORMAX))   #endif      #ifdef COMBINE_METHOD_INT         #define COMBINE_ALPHA_SUM(aS,aL) \ -  CCUT((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS)) +  CCUT((COLORMAX*DOUBLE_TO_INT(aL))+(COLORMAX-DOUBLE_TO_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)*((int)(COLORMAX-(aL)))*(aS))+ \ -  ((L)*((int)(aL))*COLORMAX))/ \ -  (((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS))) ) ) +  ( (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))) ) )      #define COMBINE_ALPHA_V(S,L,aS,aL,V) \    COMBINE_ALPHA((S),(L),(aS),((aL)*(V)))
537:   #endif      #define COMBINE(P,A) CCUT((DOUBLE_TO_INT(P))*(A)) - #define COMBINE_A(P,A) ((COLORTYPE)((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) ((COLORTYPE)DOUBLE_TO_INT(COLORMAX*(Z))) + #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; \
1416:   #undef L_OPER      #define LM_FUNC lm_modulo - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((A)%((B)?(B):1))   #include "layer_oper.h"   #undef LM_FUNC
1442:   #undef L_OPER      #define LM_FUNC lm_invmodulo - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((B)%((A)?(A):1))   #include "layer_oper.h"   #undef LM_FUNC
1452:   #undef L_USE_SA      #define LM_FUNC lm_difference - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) abs((A)-(B))   #include "layer_oper.h"   #undef LM_FUNC
1460:   #undef L_OPER      #define LM_FUNC lm_max - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) MAXIMUM((A),(B))   #include "layer_oper.h"   #undef LM_FUNC
1468:   #undef L_OPER      #define LM_FUNC lm_min - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) MINIMUM((A),(B))   #include "layer_oper.h"   #undef LM_FUNC
1476:   #undef L_OPER      #define LM_FUNC lm_bitwise_and - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((A)&(B))   #include "layer_oper.h"   #undef LM_FUNC
1484:   #undef L_OPER      #define LM_FUNC lm_bitwise_or - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((A)|(B))   #include "layer_oper.h"   #undef LM_FUNC
1492:   #undef L_OPER      #define LM_FUNC lm_bitwise_xor - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) ((A)^(B))   #include "layer_oper.h"   #undef LM_FUNC
1500:   #undef L_OPER      #define LM_FUNC lm_equal - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)==(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1508:   #undef L_OPER      #define LM_FUNC lm_not_equal - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)!=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1516:   #undef L_OPER      #define LM_FUNC lm_less - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)>(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1524:   #undef L_OPER      #define LM_FUNC lm_more - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)<(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1532:   #undef L_OPER      #define LM_FUNC lm_less_or_equal - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)>=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1540:   #undef L_OPER      #define LM_FUNC lm_more_or_equal - #define L_TRUNC(X) ((COLORTYPE)(X)) + #define L_TRUNC(X) (DOUBLE_TO_COLORTYPE(X))   #define L_OPER(A,B) (((A)<=(B))?COLORMAX:0)   #include "layer_oper.h"   #undef LM_FUNC
1999:    if (!la) /* full opaque */    {    rgb_group a; -  a.r=a.g=a.b=COLORMAX-(COLORTYPE)(alpha*COLORMAX); +  a.r=a.g=a.b=COLORMAX-DOUBLE_TO_COLORTYPE(alpha*COLORMAX);    smear_color(da,a,len);    }    else
2093:    || !l)    {    *d=*s; -  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); +  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);    }    else    { -  d->r=s->r+(COLORTYPE)(alpha*l->r); -  d->g=s->g+(COLORTYPE)(alpha*l->g); -  d->b=s->b+(COLORTYPE)(alpha*l->b); +  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);    -  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->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++; sa++; la++; s++; d++;    }