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

version» Context lines:

pike.git/src/modules/Image/layers.c:682:       smear_color(THIS->sfill,THIS->fill,SNUMPIXS);    smear_color(THIS->sfill_alpha,THIS->fill_alpha,SNUMPIXS);   }      static void free_layer(struct layer *UNUSED(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 *UNUSED(dummy))   {    free_layer(THIS);   }      /*   **! method object set_image(object(Image.Image) image)   **! method object set_image(object(Image.Image) image,object(Image.Image) alpha_channel)
pike.git/src/modules/Image/layers.c:834:   **! method object set_alpha_value(float value)   **! method float 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_TYPE f; -  get_all_args("set_alpha_value",args,"%F",&f); +  get_all_args(NULL,args,"%F",&f);    if (f<0.0 || f>1.0)    SIMPLE_ARG_TYPE_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);
pike.git/src/modules/Image/layers.c:1189:   **! Set/query layer offset.   **!   **! method int xsize()   **! method int ysize()   **! Query layer offset. This is the same as layer   **! image/alpha image size.   */      static void image_layer_set_offset(INT32 args)   { -  get_all_args("set_offset",args,"%d%d", /* INT32! */ +  get_all_args(NULL,args,"%d%d", /* INT32! */    &(THIS->xoffs),&(THIS->yoffs));    pop_n_elems(args);    ref_push_object(THISOBJ);   }      static void image_layer_xoffset(INT32 args)   {    pop_n_elems(args);    push_int(THIS->xoffs);   }
pike.git/src/modules/Image/layers.c:1230:   **! method object set_tiled(int yes)   **! method int tiled()   **! Set/query <i>tiled</i> flag. If set, the   **! image and alpha channel will be tiled rather   **! then framed by the <ref>fill</ref> values.   */      static void image_layer_set_tiled(INT32 args)   {    INT_TYPE tiled; -  get_all_args("set_tiled",args,"%i",&tiled); +  get_all_args(NULL,args,"%i",&tiled);    THIS->tiled=!!tiled;    THIS->really_optimize_alpha=really_optimize_p(THIS);    pop_n_elems(args);    ref_push_object(THISOBJ);   }      static void image_layer_tiled(INT32 args)   {    pop_n_elems(args);    push_int(THIS->tiled);
pike.git/src/modules/Image/layers.c:1344:    {    pop_n_elems(args-1);    try_parameter_pair("image","alpha",image_layer_set_image);       try_parameter("mode",image_layer_set_mode);    try_parameter("alpha_value",image_layer_set_alpha_value);       try_parameter_pair("xoffset","yoffset",image_layer_set_offset);    try_parameter_pair("fill","fill_alpha",image_layer_set_fill);    try_parameter("tiled",image_layer_set_tiled); +  pop_stack();    }    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 */ +  get_all_args(NULL,args,"%d%d", /* watch the type: INT32 */    &(THIS->xsize),&(THIS->ysize));    if (args>2)    if (!image_color_arg(2-args,&col))    SIMPLE_ARG_TYPE_ERROR("create",3,"Image.Color");       if (args>3)    if (!image_color_arg(3-args,&alpha))    SIMPLE_ARG_TYPE_ERROR("create",4,"Image.Color"); -  +  pop_n_elems(args);       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);    push_int(alpha.r);    push_int(alpha.g);    push_int(alpha.b);    push_object(clone_object(image_program,5));       image_layer_set_image(2); -  +  pop_stack();    }    else if (TYPEOF(Pike_sp[-args]) == T_OBJECT || args>1)    {    if (args>2)    {    image_layer_set_mode(args-2); -  pop_stack(); +  pop_n_elems(args-2);    args=2;    }    image_layer_set_image(args); -  +  pop_stack();    }    else    SIMPLE_ARG_TYPE_ERROR("create",1,"mapping|int|Image.Image");   }      /*** layer object *****************************************/      /*   **! method mapping(string:mixed)|string cast()   **! ([ "xsize":int,
pike.git/src/modules/Image/layers.c:2173:    }    else if (alpha==1.0)    {    if (!la) /* no layer alpha => full opaque */    {    memcpy(d,l,sizeof(rgb_group)*len);    smear_color(da,white,len);    }    else    { +  UINT64 *rnd;    push_random_string(len*8); -  UINT64 *rnd = (UINT64*)Pike_sp[-1].u.string->str; +  rnd = (UINT64*)Pike_sp[-1].u.string->str;    while (len--)    {    if (rnd[len]%(255*255) <    (unsigned)(la->r*87 + la->g*127 + la->b*41))    *d=*l,*da=white;    else    *d=*s,*da=*sa;    l++; s++; la++; sa++; da++; d++;    }    pop_stack();    }    }    else    {    int v = (int)(COLORMAX*alpha);    if (!la) /* no layer alpha => full opaque */    { -  +  unsigned char *rnd;    push_random_string(len); -  unsigned char *rnd = (unsigned char*)Pike_sp[-1].u.string->str; +  rnd = (unsigned char*)Pike_sp[-1].u.string->str;    while (len--)    {    if (rnd[len] < (unsigned)v)    *d=*l,*da=white;    else    *d=*s,*da=*sa;    l++; s++; sa++; da++; d++;    }    pop_stack();    }    else    { -  +  UINT64 *rnd;    push_random_string(len*8); -  UINT64 *rnd = (UINT64*)Pike_sp[-1].u.string->str; +  rnd = (UINT64*)Pike_sp[-1].u.string->str;    while (len--)    {    if (rnd[len]%(255*255) <    (unsigned)((la->r*87 + la->g*127 + la->b*41)>>8)*v)    *d=*l,*da=white;    else    *d=*s,*da=*sa;    l++; s++; la++; sa++; da++; d++;    }    pop_stack();
pike.git/src/modules/Image/layers.c:2730: Inside #if defined(LAYERS_DUAL)
   aline1=malloc(sizeof(rgb_group)*width + RGB_VEC_PAD);    line2=malloc(sizeof(rgb_group)*width + RGB_VEC_PAD);    aline2=malloc(sizeof(rgb_group)*width + RGB_VEC_PAD);    if (!line1 || !aline1    !line2 || !aline2)    {    if (line1) free(line1);    if (aline1) free(aline1);    if (line2) free(line2);    if (aline2) free(aline2); -  resource_error(NULL,0,0,"memory",4*(sizeof(rgb_group)*width + RGB_VEC_PAD), -  "Out of memory.\n"); +  out_of_memory_error(NULL, -1, 4*(sizeof(rgb_group)*width + RGB_VEC_PAD));    }   #endif       da=dest->alp->img;    d=dest->img->img;       /* loop over lines */    for (y=0; y<dest->ysize; y++)    {    if (layers>1 || layer[0]->row_func!=lm_normal ||
pike.git/src/modules/Image/layers.c:2865:    ONERROR err;       if (!args)    SIMPLE_WRONG_NUM_ARGS_ERROR("lay",1);       if (TYPEOF(Pike_sp[-args]) != T_ARRAY)    SIMPLE_ARG_TYPE_ERROR("lay",1,"array(Image.Layer|mapping)");       if (args>1)    { -  get_all_args("lay",args-1,"%i%i%i%i", +  get_all_args(NULL,args-1,"%i%i%i%i",    &xoffset,&yoffset,&xsize,&ysize);    if (xsize<1)    SIMPLE_ARG_TYPE_ERROR("lay",4,"int(1..)");    if (ysize<1)    SIMPLE_ARG_TYPE_ERROR("lay",5,"int(1..)");    }       layers=(a=Pike_sp[-args].u.array)->size;       if (!layers) /* dummy return empty layer */
pike.git/src/modules/Image/layers.c:3042:   **! if there was no cropping to be done.   */      static void image_layer_crop(INT32 args)   {    struct layer *l;    INT_TYPE x,y,xz,yz,xi,yi;    int zot=0;    struct image *img = NULL;    -  get_all_args("crop",args,"%i%i%i%i",&x,&y,&xz,&yz); +  get_all_args(NULL,args,"%i%i%i%i",&x,&y,&xz,&yz);       l=clone_this_layer();    if (x<=l->xoffs) x=l->xoffs; else zot++;    if (y<=l->yoffs) y=l->yoffs; else zot++;    if (l->xsize+l->xoffs<=x+xz) xz=l->xsize-(x-l->xoffs); else zot++;    if (l->ysize+l->yoffs<=y+yz) yz=l->ysize-(y-l->yoffs); else zot++;       xi=x-l->xoffs;    yi=y-l->yoffs;    l->xoffs=x;
pike.git/src/modules/Image/layers.c:3150:   **!   **! see also: crop, Image.Image->autocrop   */      static void image_layer_find_autocrop(INT32 args)   {    INT32 x1=0,y1=0,x2=THIS->xsize-1,y2=THIS->ysize-1;    INT_TYPE l=1,r=1,t=1,b=1;       if (args>3) -  get_all_args("find_autocrop",args,"%i%i%i%i",&l,&r,&t,&b); +  get_all_args(NULL,args,"%i%i%i%i",&l,&r,&t,&b);       if (!THIS->tiled) {    if (THIS->alpha)    {    img_find_autocrop(THIS->alp, &x1,&y1,&x2,&y2,    0,l,r,t,b,1,THIS->fill_alpha);    if (THIS->image &&    (THIS->fill_alpha.r!=0 ||    THIS->fill_alpha.g!=0 || /* non-transparent fill */    THIS->fill_alpha.b!=0)) /* check image too */