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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.36 1999/05/25 12:00:22 mirar Exp $ */ + /* $Id: blit.c,v 1.37 1999/06/18 19:19:14 mirar Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.36 1999/05/25 12:00:22 mirar Exp $ + **! $Id: blit.c,v 1.37 1999/06/18 19:19:14 mirar Exp $   **! class Image   */      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"   #include "pike_macros.h"   #include "object.h"
pike.git/src/modules/Image/blit.c:210:       if (x1>x2) x1^=x2,x2^=x1,x1^=x2;    if (y1>y2) y1^=y2,y2^=y1,y1^=y2;       if (x1==0 && y1==0 &&    img->xsize-1==x2 && img->ysize-1==y2)    {    *dest=*img;    new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) + 1);    if (!new) -  error("Out of memory.\n"); +  resource_error(NULL,0,0,"memory",0,"Out of memory.\n");    THREADS_ALLOW();    MEMCPY(new,img->img,(x2-x1+1)*(y2-y1+1)*sizeof(rgb_group));    THREADS_DISALLOW();    dest->img=new;    return;    }       new=malloc( (x2-x1+1)*(y2-y1+1)*sizeof(rgb_group) +1);    if (!new) -  error("Out of memory.\n"); +  resource_error(NULL,0,0,"memory",0,"Out of memory.\n");       img_clear(new,THIS->rgb,(x2-x1+1)*(y2-y1+1));       dest->xsize=x2-x1+1;    dest->ysize=y2-y1+1;       xp=MAXIMUM(0,-x1);    yp=MAXIMUM(0,-y1);    xs=MAXIMUM(0,x1);    ys=MAXIMUM(0,y1);
pike.git/src/modules/Image/blit.c:251:    dest->xsize,    img->xsize);       dest->img=new;   }      void img_clone(struct image *newimg,struct image *img)   {    if (newimg->img) free(newimg->img);    newimg->img=malloc(sizeof(rgb_group)*img->xsize*img->ysize +1); -  if (!newimg->img) error("Out of memory!\n"); +  if (!newimg->img) resource_error(NULL,0,0,"memory",0,"Out of memory.\n");    THREADS_ALLOW();    MEMCPY(newimg->img,img->img,sizeof(rgb_group)*img->xsize*img->ysize);    THREADS_DISALLOW();    newimg->xsize=img->xsize;    newimg->ysize=img->ysize;    newimg->rgb=img->rgb;   }      /*   **! method object paste(object image)
pike.git/src/modules/Image/blit.c:284:   */      void image_paste(INT32 args)   {    struct image *img=NULL;    INT32 x1,y1,x2,y2,blitwidth,blitheight;       if (args<1    || sp[-args].type!=T_OBJECT    || !(img=(struct image*)get_storage(sp[-args].u.object,image_program))) -  error("illegal argument 1 to image->paste()\n"); +  bad_arg_error("image->paste",sp-args,args,1,"",sp+1-1-args, +  "Bad argument 1 to image->paste()\n");    if (!THIS->img) return;       if (!img->img) return;       if (args>1)    {    if (args<3    || sp[1-args].type!=T_INT    || sp[2-args].type!=T_INT) -  error("illegal arguments to image->paste()\n"); +  bad_arg_error("image->paste",sp-args,args,0,"",sp-args, +  "Bad arguments to image->paste()\n");    x1=sp[1-args].u.integer;    y1=sp[2-args].u.integer;    }    else x1=y1=0;       if(x1 >= THIS->xsize || y1 >= THIS->ysize) /* Per */    {    pop_n_elems(args);    ref_push_object(THISOBJ);    return;
pike.git/src/modules/Image/blit.c:362:   void image_paste_alpha(INT32 args)   {    struct image *img;    INT32 x1,y1;       if (args<2    || sp[-args].type!=T_OBJECT    || !sp[-args].u.object    || !(img=(struct image*)get_storage(sp[-args].u.object,image_program))    || sp[1-args].type!=T_INT) -  error("illegal arguments to image->paste_alpha()\n"); +  bad_arg_error("image->paste_alpha",sp-args,args,0,"",sp-args, +  "Bad arguments to image->paste_alpha()\n");    if (!THIS->img) return;    if (!img->img) return;    THIS->alpha=(unsigned char)(sp[1-args].u.integer);       if (args>=4)    {    if (sp[2-args].type!=T_INT    || sp[3-args].type!=T_INT) -  error("illegal arguments to image->paste_alpha()\n"); +  bad_arg_error("image->paste_alpha",sp-args,args,0,"",sp-args, +  "Bad arguments to image->paste_alpha()\n");    x1=sp[2-args].u.integer;    y1=sp[3-args].u.integer;    }    else x1=y1=0;       if(x1 >= THIS->xsize || y1 >= THIS->ysize) /* Per */    {    pop_n_elems(args);    ref_push_object(THISOBJ);    return;
pike.git/src/modules/Image/blit.c:447:    INT32 x1,y1,x,y,x2,y2,smod,dmod,mmod;    rgb_group *s,*d,*m;    float q;      CHRONO("image_paste_mask init");       if (args<2)    error("illegal number of arguments to image->paste_mask()\n");    if (sp[-args].type!=T_OBJECT    || !(img=(struct image*)get_storage(sp[-args].u.object,image_program))) -  error("illegal argument 1 to image->paste_mask()\n"); +  bad_arg_error("image->paste_mask",sp-args,args,1,"",sp+1-1-args, +  "Bad argument 1 to image->paste_mask()\n");    if (sp[1-args].type!=T_OBJECT    || !(mask=(struct image*)get_storage(sp[1-args].u.object,image_program))) -  error("illegal argument 2 to image->paste_mask()\n"); +  bad_arg_error("image->paste_mask",sp-args,args,2,"",sp+2-1-args, +  "Bad argument 2 to image->paste_mask()\n");    if (!THIS->img) return;       if (!mask->img) return;    if (!img->img) return;       if (args>=4)    {    if (sp[2-args].type!=T_INT    || sp[3-args].type!=T_INT)    error("illegal coordinate arguments to image->paste_mask()\n");
pike.git/src/modules/Image/blit.c:547:   void image_paste_alpha_color(INT32 args)   {    struct image *mask;    INT32 x1,y1,x,y,x2,y2;    rgb_group rgb,*d,*m;    INT32 mmod,dmod;    float q;    int arg=1;       if (args<1) -  error("too few arguments to image->paste_alpha_color()\n"); +  SIMPLE_TOO_FEW_ARGS_ERROR("image->paste_alpha_color",1);    if (sp[-args].type!=T_OBJECT    || !sp[-args].u.object    || !(mask=(struct image*)get_storage(sp[-args].u.object,image_program))) -  error("illegal argument 1 to image->paste_alpha_color()\n"); +  bad_arg_error("image->paste_alpha_color",sp-args,args,1,"",sp+1-1-args, +  "Bad argument 1 to image->paste_alpha_color()\n");    if (!THIS->img) return;    if (!mask->img) return;       if (args==6 || args==4 || args==2 || args==3) /* color at arg 2.. */    arg=1+getrgb(THIS,1,args,3,"image->paste_alpha_color()\n");    if (args>arg+1)    {    if (sp[arg-args].type!=T_INT    || sp[1+arg-args].type!=T_INT)    error("illegal coordinate arguments to image->paste_alpha_color()\n");