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

version» Context lines:

pike.git/src/modules/Image/layers.c:21:   #include "object.h"   #include "interpret.h"   #include "svalue.h"   #include "array.h"   #include "mapping.h"   #include "threads.h"   #include "builtin_functions.h"   #include "dmalloc.h"   #include "operators.h"   #include "module_support.h" + #include "pike_types.h"      #include "image.h"      extern struct program *image_program;   extern struct program *image_layer_program;   extern struct program *image_colortable_program;      static struct mapping *colors=NULL;   static struct object *colortable=NULL;   static struct array *colornames=NULL;
pike.git/src/modules/Image/layers.c:1417:   **! "xoffset":int,   **! "yoffset":int,   **! "fill":image,   **! "fill_alpha":image   **! "tiled":int,   **! "mode":string   **! ])    */   static void image_layer_cast(INT32 args)   { +  struct pike_string *type; +     if (!args)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->cast",1); -  if (TYPEOF(Pike_sp[-args]) == T_STRING || -  Pike_sp[-args].u.string->size_shift) +  +  type = Pike_sp[-args].u.string; +  pop_n_elems(args); /* type have at least one more reference. */ +  +  if (type == literal_mapping_string)    { -  if (strncmp(Pike_sp[-args].u.string->str,"mapping",7)==0) -  { +     int n=0; -  pop_n_elems(args); +        push_text("xsize"); push_int(THIS->xsize); n++;    push_text("ysize"); push_int(THIS->ysize); n++;    push_text("image"); image_layer_image(0); n++;    push_text("alpha"); image_layer_alpha(0); n++;    push_text("xoffset"); push_int(THIS->xoffs); n++;    push_text("yoffset"); push_int(THIS->yoffs); n++;    push_text("alpha_value"); push_float(THIS->alpha_value); n++;    push_text("fill"); image_layer_fill(0); n++;    push_text("fill_alpha"); image_layer_fill_alpha(0); n++;    push_text("tiled"); push_int(THIS->tiled); n++;    push_text("mode"); image_layer_mode(0); n++;       f_aggregate_mapping(n*2); -  -  return; +     } -  else if (strncmp(Pike_sp[-args].u.string->str,"string",6)==0) +  else if (type == literal_string_string)    {    size_t size = THIS->xsize*THIS->ysize, i;    struct pike_string *s = begin_shared_string(size*4);    rgb_group *img = 0;    rgb_group *alp = 0;    -  pop_n_elems(args); +     if(THIS->img)    img = THIS->img->img;    if(THIS->alp)    alp = THIS->alp->img;       if(img && alp)    for(i=0; i<size; i++) {    s->str[i*4+0] = img[i].r;    s->str[i*4+1] = img[i].g;    s->str[i*4+2] = img[i].b;
pike.git/src/modules/Image/layers.c:1481:    for(i=0; i<size; i++) {    s->str[i*4+0] = 255;    s->str[i*4+1] = 255;    s->str[i*4+2] = 255;    s->str[i*4+3] = alp[i].r;    }    else    memset(s->str, 0, size*4);       push_string(end_shared_string(s)); -  return; +     } -  +  else +  push_undefined();   } -  SIMPLE_BAD_ARG_ERROR("Image.Colortable->cast",1, -  "string(\"mapping\"|\"string\")"); +     - } -  +    /*** 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,double alpha)   {    /* la may be NULL, no other */       if (alpha==0.0) /* optimized */    {
pike.git/src/modules/Image/layers.c:3295:    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("_sprintf",image_layer__sprintf,    tFunc(tInt tMapping,tString),0);    ADD_FUNCTION("cast",image_layer_cast, -  tFunc(tString,tMapping),0); +  tFunc(tString,tMapping),ID_PROTECTED);          ADD_FUNCTION("clone",image_layer_clone,    tFunc(tNone,tObj),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);