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

version» Context lines:

pike.git/src/modules/Image/layers.c:1:   /*   **! module Image   **! note - **! $Id: layers.c,v 1.2 1999/04/18 22:04:20 mirar Exp $ + **! $Id: layers.c,v 1.3 1999/04/19 16:50:47 mirar Exp $   **! class Layer   */      #include "global.h"   #include <config.h>    - RCSID("$Id: layers.c,v 1.2 1999/04/18 22:04:20 mirar Exp $"); + RCSID("$Id: layers.c,v 1.3 1999/04/19 16:50:47 mirar Exp $");      #include "config.h"      #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "array.h"
pike.git/src/modules/Image/layers.c:147:    struct pike_string *ps;   } layer_mode[]=   {    {"normal", lm_normal, 1, NULL },   /* {"dissolve", lm_dissolve, 1, NULL }, */   /* {"behind", lm_behind, 1, NULL }, */   /* {"multiply", lm_multiply, 1, NULL }, */   /* {"screen", lm_screen, 1, NULL }, */   /* {"overlay", lm_overlay, 1, NULL }, */   /* {"difference", lm_difference, 1, NULL }, */ - /* {"addition", lm_addition, 1, NULL }, */ + /* {"add", lm_addition, 1, NULL }, */   /* {"subtract", lm_subtract, 1, NULL }, */   /* {"darken", lm_darken, 1, NULL }, */   /* {"lighten", lm_lighten, 1, NULL }, */   /* {"hue", lm_hue, 1, NULL }, */   /* {"saturation", lm_saturation, 1, NULL }, */   /* {"color", lm_color, 1, NULL }, */   /* {"value", lm_value, 1, NULL }, */   /* {"divide", lm_divide, 1, NULL }, */   /* {"erase", lm_erase, 1, NULL }, */   /* {"replace", lm_replace, 1, NULL }, */   } ;      #define LAYER_MODES ((int)NELEM(layer_mode))    -  + /* +  + Px=pixel, Ax=alpha [0-1], Rx,Gx,Bx, Hx,Sx,Vx = kanaler + Xs=källbild + Xl=aktuellt lager + Xd=målbild +  + normal Pd=(Pl*Al+Ps*(1-Al)*As)/(Al+(1-Al)*As) +  Ad=(Al+(1-Al)*As) +  + add Pd=Pl*Al+Ps*As +  Ad=(Al+(1-Al)*As) +  + subtract Pd=Ps-Pl*Al +  Ad=(Al+(1-Al)*As) +  + multiply Pd=Ps*Pl +  Ad=(Al+(1-Al)*As) +  + divide Pd=Ps/Pl +  Ad=As +  + dissolve i=round(random(Al)) typ +  Pd=Al*i+As*(1-i) +  Ad=i+As +  + behind + screen + overlay + difference + darken + lighten + hue + saturation + color + value + erase + replace +  + */ +  +  +    /*** layer helpers ****************************************/      static INLINE void smear_color(rgb_group *d,rgb_group s,int len)   {    while (len--)    *(d++)=s;   }      /*** layer object : init and exit *************************/   
pike.git/src/modules/Image/layers.c:298:      static void image_layer_image(INT32 args)   {    pop_n_elems(args);    if (THIS->image)    ref_push_object(THIS->image);    else    push_int(0);   }    +    static void image_layer_alpha(INT32 args)   {    pop_n_elems(args);    if (THIS->alpha)    ref_push_object(THIS->alpha);    else    push_int(0);   }      /*
pike.git/src/modules/Image/layers.c:804:    return;    }    }    SIMPLE_BAD_ARG_ERROR("Image.Colortable->cast",1,    "string(\"mapping\"|\"array\"|\"string\")");      }      /*** layer helpers ************************************/    - #define ALPHA_METHOD_INT + #define ALPHA_METHOD_FLOAT      #ifdef ALPHA_METHOD_INT      #define CCUT(Z) ((COLORTYPE)((Z)/COLORMAX))      #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:827:    ((L)*((int)(aL))*COLORMAX))/ \    (((COLORMAX*(int)(aL))+(COLORMAX-(int)(aL))*(aS))) ) )      #define COMBINE_ALPHA_V(S,L,aS,aL,V) \    COMBINE_ALPHA(S,(int)((L)*(V)),aS,aL)      #else   #ifdef ALPHA_METHOD_FLOAT      #define qMAX (1.0/COLORMAX) - #define C2F(Z) (qMAX*Z) + #define C2F(Z) (qMAX*(Z))   #define CCUT(Z) ((COLORTYPE)(qMAX*Z))      #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)) ) ) +  ( (COLORTYPE)( ( (S)*(1.0-C2F(aL))*C2F(aS) + (L)*C2F(aL) ) / \ +  ( (C2F(aL)+(1-C2F(aL))*C2F(aS))) ) )      #define COMBINE_ALPHA_V(S,L,aS,aL,V) \    COMBINE_ALPHA(S,(L)*(V),aS,aL)      #define COMBINE_ALPHA_SUM(aS,aL) \ -  ((COLORTYPE)(COLORMAX*(C2F(aL)+(1.0-C2F(aL))*aS)) +  ((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 ALPHA_METHOD */   #error unknown ALPHA_METHOD - #endif ALPHA_METHOD_FLOAT + #endif /* ALPHA_METHOD_FLOAT */    - #endif ALPHA_INT_IS_FASTER + #endif       -  +    /*** layer mode definitions ***************************/      static void lm_normal(rgb_group *s,rgb_group *l,rgb_group *d,    rgb_group *sa,rgb_group *la,rgb_group *da,    int len,float alpha)   {    /* la may be NULL, no other */       if (alpha==0.0) /* optimized */    {
pike.git/src/modules/Image/layers.c:959:    ALPHA_ADD_V(s,l,d,sa,la,da,alpha,b);      #undef ALPHA_ADD_V    l++; s++; la++; sa++; da++; d++;    }    return;    }   }       + static void lm_add(rgb_group *s,rgb_group *l,rgb_group *d, +  rgb_group *sa,rgb_group *la,rgb_group *da, +  int len,float alpha) +  { +  } +    /*** the add-layer function ***************************/      static void INLINE img_lay_first_line(struct layer *l,    int xoffs,int xsize,    int y, /* in _this_ layer */    rgb_group *d,rgb_group *da)   {    if (!l->tiled)    {    rgb_group *s,*sa;