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.41 2000/02/03 19:02:22 grubba Exp $ + **! $Id: layers.c,v 1.42 2000/02/08 03:38:56 per Exp $   **! class Layer   **! see also: layers   **!      **!   **!   **! <add_appendix name="layers" title="Image.Layer modes">   **! <dl compact>   **! <dt><i>The variables in the expression:</i>   **! <dt>L<dd><i>The active layer</i>
pike.git/src/modules/Image/layers.c:208:   **! }   **!   **! </execute>   **! </add_appendix>   */      #include "global.h"      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.41 2000/02/03 19:02:22 grubba Exp $"); + RCSID("$Id: layers.c,v 1.42 2000/02/08 03:38:56 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:283:    rgb_group fill_alpha; /* fill alpha */       rgb_group sfill[SNUMPIXS]; /* pre-calculated rows */    rgb_group sfill_alpha[SNUMPIXS];       int tiled; /* true if tiled */       lm_row_func *row_func;/* layer mode */    int optimize_alpha;    int really_optimize_alpha; +  +  struct mapping *misc; /* Misc associated data. Added by per, +  rather useful for some things... */   };      #undef THIS   #define THIS ((struct layer *)(fp->current_storage))   #define THISOBJ (fp->current_object)      #define LMFUNC(X) \    static void X(rgb_group *s,rgb_group *l,rgb_group *d, \    rgb_group *sa,rgb_group *la,rgb_group *da, \    int len,double alpha)
pike.git/src/modules/Image/layers.c:673:    THIS->alpha=NULL;    THIS->img=NULL;    THIS->alp=NULL;    THIS->fill=black;    THIS->fill_alpha=black;    THIS->tiled=0;    THIS->alpha_value=1.0;    THIS->row_func=lm_normal;    THIS->optimize_alpha=1;    THIS->really_optimize_alpha=1; +  THIS->misc=0;       smear_color(THIS->sfill,THIS->fill,SNUMPIXS);    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS);   }      static void free_layer(struct layer *l)   {    if (THIS->image) free_object(THIS->image);    if (THIS->alpha) free_object(THIS->alpha); -  +  if (THIS->misc) free_mapping(THIS->misc);    THIS->image=NULL;    THIS->alpha=NULL;    THIS->img=NULL;    THIS->alp=NULL;   }      static void exit_layer(struct object *dummy)   {    free_layer(THIS);   }
pike.git/src/modules/Image/layers.c:774:    THIS->alp=img;    }    else    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2,    "object(Image)|int(0)");       pop_n_elems(args);    ref_push_object(THISOBJ);   }    + static void image_layer_get_misc_value( INT32 args ) + { +  if( args != 1 ) +  error("Wrong number of arguments to get_misc_value\n"); +  if( THIS->misc ) +  { +  ref_push_mapping( THIS->misc ); +  stack_swap(); +  f_index( 2 ); +  } else { +  pop_n_elems( args ); +  push_int( 0 ); +  } + } +  + /* + **! method mixed set_misc_value( mixed what, mixed to ) + **! method mixed get_misc_value( mixed what ) + **! Set or query misc. attributes for the layer. + **! + **! As an example, the XCF and PSD image decoders set the 'name' attribute + **! to the name the layer had in the source file. + */ + static void image_layer_set_misc_value( INT32 args ) + { +  if( args != 2 ) +  error("Wrong number of arguments to set_misc_value\n"); +  if( !THIS->misc ) +  THIS->misc = allocate_mapping( 4 ); +  +  mapping_insert( THIS->misc, sp-2, sp-1 ); +  stack_swap(); +  pop_stack(); + } +    static void image_layer_image(INT32 args)   {    pop_n_elems(args);    if (THIS->image)    ref_push_object(THIS->image);    else    push_int(0);   }      
pike.git/src/modules/Image/layers.c:2837:       for (i=0; i<LAYER_MODES; i++)    layer_mode[i].ps=make_shared_string(layer_mode[i].name);       /* layer object */       ADD_STORAGE(struct layer);    set_init_callback(init_layer);    set_exit_callback(exit_layer);    +     ADD_FUNCTION("create",image_layer_create,    tOr4(tFunc(tNone,tVoid),    tFunc(tObj tOr(tObj,tVoid) tOr(tString,tVoid),tVoid),    tFunc(tLayerMap,tVoid),    tFunc(tInt tInt    tOr(tColor,tVoid) tOr(tColor,tVoid),tVoid)),0);       ADD_FUNCTION("cast",image_layer_cast,    tFunc(tString,tMapping),0);   
pike.git/src/modules/Image/layers.c:2863:    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_alpha_value,    tFunc(tFloat,tObj),0);    ADD_FUNCTION("set_tiled",image_layer_set_tiled,tFunc(tInt,tObj),0);    +  ADD_FUNCTION("set_misc_value", image_layer_set_misc_value, +  tFunc(tMixed tMixed, tMixed),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);    ADD_FUNCTION("descriptions",image_layer_descriptions,    tFunc(tNone,tArr(tStr)),0);
pike.git/src/modules/Image/layers.c:2886:       ADD_FUNCTION("xoffset",image_layer_xoffset,tFunc(tNone,tInt),0);    ADD_FUNCTION("yoffset",image_layer_yoffset,tFunc(tNone,tInt),0);       ADD_FUNCTION("alpha_value",image_layer_alpha_value,tFunc(tNone,tFloat),0);    ADD_FUNCTION("fill",image_layer_fill,tFunc(tNone,tObj),0);    ADD_FUNCTION("fill_alpha",image_layer_fill_alpha,tFunc(tNone,tObj),0);       ADD_FUNCTION("tiled",image_layer_tiled,tFunc(tNone,tInt01),0);    +  ADD_FUNCTION("get_misc_value", image_layer_get_misc_value, +  tFunc(tMixed, tMixed),0 ); +     /* image-object operations */       ADD_FUNCTION("crop",image_layer_crop,    tFunc(tInt tInt tInt tInt,tObj),0);    ADD_FUNCTION("autocrop",image_layer_autocrop,    tFuncV(tNone,tOr(tVoid,tInt),tObj),0);    ADD_FUNCTION("find_autocrop",image_layer_find_autocrop,    tFuncV(tNone,tOr(tVoid,tInt),tObj),0);       /*