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

version» Context lines:

pike.git/src/modules/Image/layers.c:725:    if (THIS->alpha)    free_object(THIS->alpha);    THIS->alpha=NULL;    THIS->alp=NULL;       if (args>=1) {    if ( TYPEOF(Pike_sp[-args]) != T_OBJECT )    {    if (TYPEOF(Pike_sp[-args]) != T_INT ||    Pike_sp[-args].u.integer!=0) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",1, -  "object(Image)|int(0)"); +  SIMPLE_BAD_ARG_ERROR("set_image",1,"Image.Image|int(0..0)");    }    else if ((img=get_storage(Pike_sp[-args].u.object,image_program)))    {    THIS->image=Pike_sp[-args].u.object;    add_ref(THIS->image);    THIS->img=img;    THIS->xsize=img->xsize;    THIS->ysize=img->ysize;    }    else -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",1, -  "object(Image)|int(0)"); +  SIMPLE_BAD_ARG_ERROR("set_image",1, "Image.Image|int(0..0)");    }       if (args>=2) {    if ( TYPEOF(Pike_sp[1-args]) != T_OBJECT )    {    if (TYPEOF(Pike_sp[1-args]) != T_INT ||    Pike_sp[1-args].u.integer!=0) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2, -  "object(Image)|int(0)"); +  SIMPLE_BAD_ARG_ERROR("set_image",2, "Image.Image|int(0..0)");    }    else if ((img=get_storage(Pike_sp[1-args].u.object,image_program)))    {    if (THIS->img &&    (img->xsize!=THIS->xsize ||    img->ysize!=THIS->ysize)) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2, -  "image of same size"); +  SIMPLE_BAD_ARG_ERROR("set_image",2, "image of same size");    if (!THIS->img)    {    THIS->xsize=img->xsize;    THIS->ysize=img->ysize;    }    THIS->alpha=Pike_sp[1-args].u.object;    add_ref(THIS->alpha);    THIS->alp=img;    }    else -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2, -  "object(Image)|int(0)"); +  SIMPLE_BAD_ARG_ERROR("set_image",2,"Image.Image|int(0..0)");    }       pop_n_elems(args);    ref_push_object(THISOBJ);   }      static void image_layer_get_misc_value( INT32 args )   {    if( args != 1 )    Pike_error("Wrong number of arguments to get_misc_value\n");
pike.git/src/modules/Image/layers.c:841:   **! 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_TYPE f;    get_all_args("set_alpha_value",args,"%F",&f);    if (f<0.0 || f>1.0) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_alpha_value",1,"float(0..1)"); +  SIMPLE_BAD_ARG_ERROR("set_alpha_value",1,"float(0..1)");    THIS->alpha_value=f;    pop_n_elems(args);    ref_push_object(THISOBJ);   }      static void image_layer_alpha_value(INT32 args)   {    pop_n_elems(args);    push_float(THIS->alpha_value);   }
pike.git/src/modules/Image/layers.c:1052:   **!   **! note:   **! image and alpha channel must be of the same size,   **! or canceled.   */      static void image_layer_set_mode(INT32 args)   {    int i;    if (args!=1) -  SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->set_mode",1); +  SIMPLE_TOO_FEW_ARGS_ERROR("set_mode",1);    if (TYPEOF(Pike_sp[-args]) != T_STRING) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_mode",1,"string"); +  SIMPLE_BAD_ARG_ERROR("set_mode",1,"string");       for (i=0; i<LAYER_MODES; i++)    if (Pike_sp[-args].u.string==layer_mode[i].ps)    {    THIS->row_func=layer_mode[i].func;    THIS->optimize_alpha=layer_mode[i].optimize_alpha;    THIS->really_optimize_alpha=really_optimize_p(THIS);       pop_n_elems(args);    ref_push_object(THISOBJ);    return;    }    -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_mode",1,"existing mode"); +  SIMPLE_BAD_ARG_ERROR("set_mode",1,"existing mode");   }      static void image_layer_mode(INT32 args)   {    int i;    pop_n_elems(args);       for (i=0; i<LAYER_MODES; i++)    if (THIS->row_func==layer_mode[i].func)    {
pike.git/src/modules/Image/layers.c:1125:   **! method object fill()   **! method object fill_alpha()   **! Set/query fill color and alpha, ie the color used "outside" the   **! image. This is mostly useful if you want to "frame"   **! a layer.   */      static void image_layer_set_fill(INT32 args)   {    if (!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("Image.Layer->set_fill",1); +  SIMPLE_TOO_FEW_ARGS_ERROR("set_fill",1);       if (TYPEOF(Pike_sp[-args]) == T_INT && !Pike_sp[-args].u.integer)    THIS->fill=black;    else    if (!image_color_arg(-args,&(THIS->fill))) -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_fill",1,"color"); +  SIMPLE_BAD_ARG_ERROR("set_fill",1,"Image.Color");       smear_color(THIS->sfill,THIS->fill,SNUMPIXS);       THIS->fill_alpha=white;    if (args>1) {    if (TYPEOF(Pike_sp[1-args]) == T_INT && !Pike_sp[1-args].u.integer)    ; /* white is good */    else    if (!image_color_arg(1-args,&(THIS->fill_alpha)))    {    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS); -  SIMPLE_BAD_ARG_ERROR("Image.Layer->set_fill",2,"color"); +  SIMPLE_BAD_ARG_ERROR("set_fill",2,"Image.Color");    }    }    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS);      #if 0    {    int i;    for (i=0; i<SNUMPIXS; i++)    fprintf(stderr,"#%02x%02x%02x ",THIS->sfill_alpha[i].r,THIS->sfill_alpha[i].g,THIS->sfill_alpha[i].b);    fprintf(stderr,"\n");
pike.git/src/modules/Image/layers.c:1361:    }    else if (TYPEOF(Pike_sp[-args]) == T_INT && args>1    && TYPEOF(Pike_sp[1-args]) == T_INT)    {    rgb_group col=black,alpha=white;       get_all_args("create",args,"%d%d", /* watch the type: INT32 */    &(THIS->xsize),&(THIS->ysize));    if (args>2)    if (!image_color_arg(2-args,&col)) -  SIMPLE_BAD_ARG_ERROR("Image.Layer",3,"Image.Color"); +  SIMPLE_BAD_ARG_ERROR("create",3,"Image.Color");       if (args>3)    if (!image_color_arg(3-args,&alpha)) -  SIMPLE_BAD_ARG_ERROR("Image.Layer",4,"Image.Color"); +  SIMPLE_BAD_ARG_ERROR("create",4,"Image.Color");       push_int(THIS->xsize);    push_int(THIS->ysize);    push_int(col.r);    push_int(col.g);    push_int(col.b);    push_object(clone_object(image_program,5));       push_int(THIS->xsize);    push_int(THIS->ysize);
pike.git/src/modules/Image/layers.c:1397:    if (args>2)    {    image_layer_set_mode(args-2);    pop_stack();    args=2;    }    image_layer_set_image(args);    pop_stack();    }    else -  SIMPLE_BAD_ARG_ERROR("Image.Layer",1,"mapping|int|Image.Image"); +  SIMPLE_BAD_ARG_ERROR("create",1,"mapping|int|Image.Image");   }      /*** layer object *****************************************/      /*   **! method mapping(string:mixed)|string cast()   **! ([ "xsize":int,   **! "ysize":int,   **! "image":image,   **! "alpha":image,
pike.git/src/modules/Image/layers.c:1421:   **! "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); +  SIMPLE_TOO_FEW_ARGS_ERROR("cast",1);       type = Pike_sp[-args].u.string;    pop_n_elems(args); /* type have at least one more reference. */       if (type == literal_mapping_string)    {    int n=0;       push_text("xsize"); push_int(THIS->xsize); n++;    push_text("ysize"); push_int(THIS->ysize); n++;
pike.git/src/modules/Image/layers.c:2894:   {    int layers,i,j;    struct layer **l;    struct object *o;    struct layer *dest;    struct array *a;    INT_TYPE xoffset=0,yoffset=0,xsize=0,ysize=0;    ONERROR err;       if (!args) -  SIMPLE_TOO_FEW_ARGS_ERROR("Image.lay",1); +  SIMPLE_TOO_FEW_ARGS_ERROR("lay",1);       if (TYPEOF(Pike_sp[-args]) != T_ARRAY) -  SIMPLE_BAD_ARG_ERROR("Image.lay",1, -  "array(Image.Layer|mapping)"); +  SIMPLE_BAD_ARG_ERROR("lay",1,"array(Image.Layer|mapping)");       if (args>1)    {    get_all_args("lay",args-1,"%i%i%i%i",    &xoffset,&yoffset,&xsize,&ysize);    if (xsize<1) -  SIMPLE_BAD_ARG_ERROR("Image.lay",4,"int(1..)"); +  SIMPLE_BAD_ARG_ERROR("lay",4,"int(1..)");    if (ysize<1) -  SIMPLE_BAD_ARG_ERROR("Image.lay",5,"int(1..)"); +  SIMPLE_BAD_ARG_ERROR("lay",5,"int(1..)");    }       layers=(a=Pike_sp[-args].u.array)->size;       if (!layers) /* dummy return empty layer */    {    pop_n_elems(args);    push_object(clone_object(image_layer_program,0));    return;    }
pike.git/src/modules/Image/layers.c:2929:    l=(struct layer**)xalloc(sizeof(struct layer *)*layers);       SET_ONERROR(err, free, l);       for (i=j=0; i<layers; i++)    {    if (TYPEOF(a->item[i]) == T_OBJECT)    {    if (!(l[j]=get_storage(a->item[i].u.object,    image_layer_program))) -  SIMPLE_BAD_ARG_ERROR("Image.lay",1, +  SIMPLE_BAD_ARG_ERROR("lay",1,    "array(Image.Layer|mapping)");    }    else if (TYPEOF(a->item[i]) == T_MAPPING)    {    push_svalue(a->item+i);    push_object(o=clone_object(image_layer_program,1));    args++;    l[j]=get_storage(o,image_layer_program);    }    else -  SIMPLE_BAD_ARG_ERROR("Image.lay",1, +  SIMPLE_BAD_ARG_ERROR("lay",1,    "array(Image.Layer|mapping)");    if (l[j]->xsize && l[j]->ysize)    j++;    }       if (!(layers = j)) /* dummy return empty layer */    {    CALL_AND_UNSET_ONERROR(err);    pop_n_elems(args);    push_object(clone_object(image_layer_program,0));
pike.git/src/modules/Image/layers.c:3240:    image_layer_crop(4);   }         static void image_layer__sprintf( INT32 args )   {    int x;    if (args != 2 )    SIMPLE_TOO_FEW_ARGS_ERROR("_sprintf",2);    if (TYPEOF(Pike_sp[-args]) != T_INT) -  SIMPLE_BAD_ARG_ERROR("_sprintf",0,"integer"); +  SIMPLE_BAD_ARG_ERROR("_sprintf",0,"int");    if (TYPEOF(Pike_sp[1-args]) != T_MAPPING)    SIMPLE_BAD_ARG_ERROR("_sprintf",1,"mapping");       x = Pike_sp[-2].u.integer;       pop_n_elems( 2 );    switch( x )    {    case 't':    push_text("Image.Layer");