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.21 1999/06/22 19:26:00 mirar Exp $ + **! $Id: layers.c,v 1.22 1999/06/28 00:43:06 per Exp $   **! class Layer   **! see also: layers   **!      **!   **!   **! <add_appendix name="layers" title="Image.Layer modes"><execute>   **! import Image;   **!   **! void write_image(string desc,
pike.git/src/modules/Image/layers.c:145:   **! }   **!   **! </execute>   **! </add_appendix>   */      #include "global.h"      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.21 1999/06/22 19:26:00 mirar Exp $"); + RCSID("$Id: layers.c,v 1.22 1999/06/28 00:43:06 per Exp $");      #include "image_machine.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:270:   LMFUNC(lm_saturation);   LMFUNC(lm_value);   LMFUNC(lm_color);   LMFUNC(lm_darken);   LMFUNC(lm_lighten);      LMFUNC(lm_dissolve);   LMFUNC(lm_behind);   LMFUNC(lm_erase);    + LMFUNC(lm_screen); + LMFUNC(lm_overlay); +    struct layer_mode_desc   {    char *name;    lm_row_func *func;    int optimize_alpha; /* alpha 0 -> skip layer */    struct pike_string *ps;   } layer_mode[]=   {    {"normal", lm_normal, 1, NULL },    {"add", lm_add, 1, NULL },
pike.git/src/modules/Image/layers.c:324:    {"value", lm_value, 1, NULL },    {"color", lm_color, 1, NULL }, /* h+s */       {"darken", lm_darken, 1, NULL },    {"lighten", lm_lighten, 1, NULL },       {"dissolve", lm_dissolve, 1, NULL },    {"behind", lm_behind, 1, NULL },    {"erase", lm_erase, 1, NULL },    - /* {"screen", lm_screen, 1, NULL }, */ - /* {"overlay", lm_overlay, 1, NULL }, */ +  {"screen", lm_screen, 1, NULL }, +  {"overlay", lm_overlay, 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
pike.git/src/modules/Image/layers.c:720:   **! method double alpha_value()   **! Set/get the general alpha value of this layer.   **! This is a float value between 0 and 1,   **! and is multiplied with the alpha channel.   */      static void image_layer_set_alpha_value(INT32 args)   {    float f;    get_all_args("Image.Layer->set_alpha_value",args,"%F",&f); -  if (f<0.0 || f>=1.0) +  if (f<0.0 || f>1.0)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_alpha_value",1,"float(0..1)");    THIS->alpha_value=f;   }      static void image_layer_alpha_value(INT32 args)   {    pop_n_elems(args);    push_float(THIS->alpha_value);   }   
pike.git/src/modules/Image/layers.c:1599:    double sh,ss,sv; \    double dh,ds,dv; \    rgb_to_hsv((S),&sh,&ss,&sv); \    rgb_to_hsv((L),&lh,&ls,&lv); \    hsv_to_rgb(sh,ss,MAXIMUM(sv,lv),&(D)); \    } while (0)   #include "layer_channel.h"   #undef L_CHANNEL_DO_V   #undef LM_FUNC    + /* screen: 255 - ((255-A)*(255-B)/255) */ +  + #define LM_FUNC lm_screen + #define L_TRUNC(X) (X<0?0:(X>255?255:X)) + #define L_OPER(A,B) 255 - CCUT((255-A)*(int)(255-B)) + #include "layer_oper.h" + #undef LM_FUNC + #undef L_TRUNC + #undef L_OPER +  + #define LM_FUNC lm_overlay + #define L_TRUNC(X) (X) + #define INT_MULT(a,b) (((a) * (b) + 0x80)>>8) + #define INT_BLEND(a,b,alpha) (INT_MULT((a)-(b), alpha) + (b)) + #define L_OPER(A,B) INT_BLEND((255-INT_MULT((255-A),(255-B))),INT_MULT(A,B),A) + /* screen mult source */ + #include "layer_oper.h" + #undef LM_FUNC + #undef L_TRUNC + #undef L_OPER +    /* darken: min v */      #define LM_FUNC lm_darken   #define L_CHANNEL_DO_V(S,L,D,A,V) \    do { \    double lh,ls,lv; \    double sh,ss,sv; \    double dh,ds,dv; \    rgb_to_hsv((S),&sh,&ss,&sv); \    rgb_to_hsv((L),&lh,&ls,&lv); \
pike.git/src/modules/Image/layers.c:2468:    tFunc(tString,tMapping),0);       /* set */       ADD_FUNCTION("set_offset",image_layer_set_offset,tFunc(tInt tInt,tObj),0);    ADD_FUNCTION("set_image",image_layer_set_image,    tFunc(tOr(tObj,tVoid) tOr(tObj,tVoid),tObj),0);    ADD_FUNCTION("set_fill",image_layer_set_fill,    tFunc(tOr(tObj,tVoid) tOr(tObj,tVoid),tObj),0);    ADD_FUNCTION("set_mode",image_layer_set_mode,tFunc(tStr,tObj),0); -  ADD_FUNCTION("set_alpha_value",image_layer_set_mode,tFunc(tFloat,tObj),0); +  ADD_FUNCTION("set_alpha_value",image_layer_set_alpha_value, +  tFunc(tFloat,tObj),0);    ADD_FUNCTION("set_tiled",image_layer_set_tiled,tFunc(tInt,tObj),0);       /* query */       ADD_FUNCTION("image",image_layer_image,tFunc(tNone,tObj),0);    ADD_FUNCTION("alpha",image_layer_alpha,tFunc(tNone,tObj),0);    ADD_FUNCTION("mode",image_layer_mode,tFunc(tNone,tStr),0);       ADD_FUNCTION("available_modes",image_layer_available_modes,    tFunc(tNone,tArr(tStr)),0);