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.53 2000/08/10 09:51:54 per Exp $ + **! $Id: layers.c,v 1.54 2000/08/12 23:06:54 grubba 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.53 2000/08/10 09:51:54 per Exp $"); + RCSID("$Id: layers.c,v 1.54 2000/08/12 23:06:54 grubba 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:731:    if (THIS->image)    free_object(THIS->image);    THIS->image=NULL;    THIS->img=NULL;       if (THIS->alpha)    free_object(THIS->alpha);    THIS->alpha=NULL;    THIS->alp=NULL;    -  if (args>=1) +  if (args>=1) {    if ( Pike_sp[-args].type!=T_OBJECT )    {    if (Pike_sp[-args].type!=T_INT ||    Pike_sp[-args].u.integer!=0)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",1,    "object(Image)|int(0)");    }    else if ((img=(struct image*)    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)"); -  +  }    -  if (args>=2) +  if (args>=2) {    if ( Pike_sp[1-args].type!=T_OBJECT )    {    if (Pike_sp[1-args].type!=T_INT ||    Pike_sp[1-args].u.integer!=0)    SIMPLE_BAD_ARG_ERROR("Image.Layer->set_image",2,    "object(Image)|int(0)");    }    else if ((img=(struct image*)    get_storage(Pike_sp[1-args].u.object,image_program)))    {
pike.git/src/modules/Image/layers.c:780:    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)"); +  }       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 )
pike.git/src/modules/Image/layers.c:996:       if (Pike_sp[-args].type==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");       smear_color(THIS->sfill,THIS->fill,SNUMPIXS);       THIS->fill_alpha=white; -  if (args>1) +  if (args>1) {    if (Pike_sp[1-args].type==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");    } -  +  }    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");    for (i=0; i<SNUMPIXS; i++)    fprintf("stderr,#%02x%02x%02x ",THIS->sfill[i].r,THIS->sfill[i].g,THIS->sfill[i].b);
pike.git/src/modules/Image/layers.c:2835:   */      static void image_layer_find_autocrop(INT32 args)   {    INT_TYPE 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,"%d%d%d%d",&l,&r,&t,&b);    -  if (!THIS->tiled) +  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 */    {    int ix1,iy1,ix2,iy2;
pike.git/src/modules/Image/layers.c:2862:    }    }    else if (THIS->image && /* image alpha is 'white'... */    (THIS->fill_alpha.r==255 ||    THIS->fill_alpha.g==255 || /* opaque fill */    THIS->fill_alpha.b==255)) /* we may be able to crop */    {    img_find_autocrop(THIS->img, &x1,&y1,&x2,&y2,    0,l,r,t,b,1,THIS->fill);    } -  +  }    push_int(x1+THIS->xoffs);    push_int(y1+THIS->yoffs);    push_int(x2-x1+1);    push_int(y2-y1+1);    f_aggregate(4);   }      void image_layer_autocrop(INT32 args)   {    image_layer_find_autocrop(args);