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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.31 1999/04/16 17:45:05 mirar Exp $ */ + /* $Id: blit.c,v 1.32 1999/05/20 17:34:34 mirar Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.31 1999/04/16 17:45:05 mirar Exp $ + **! $Id: blit.c,v 1.32 1999/05/20 17:34:34 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:73:      #define setpixel(x,y) \    (THIS->alpha? \    set_rgb_group_alpha(THIS->img[(x)+(y)*THIS->xsize],THIS->rgb,THIS->alpha): \    ((pixel(THIS,x,y)=THIS->rgb),0))      #define setpixel_test(x,y) \    (((x)<0||(y)<0||(x)>=THIS->xsize||(y)>=THIS->ysize)? \    0:(setpixel(x,y),0))    - static INLINE void getrgb(struct image *img, + static INLINE int getrgb(struct image *img,    INT32 args_start,INT32 args,char *name)   {    INT32 i; -  if (args-args_start<3) return; +  if (args-args_start<1) return 0; +  +  if (image_color_svalue(sp-args+args_start,&(img->rgb))) +  return 1; +  +  if (args-args_start<3) return 0; +     for (i=0; i<3; i++)    if (sp[-args+i+args_start].type!=T_INT)    error("Illegal r,g,b argument to %s\n",name);    img->rgb.r=(unsigned char)sp[-args+args_start].u.integer;    img->rgb.g=(unsigned char)sp[1-args+args_start].u.integer;    img->rgb.b=(unsigned char)sp[2-args+args_start].u.integer;    if (args-args_start>=4)    if (sp[3-args+args_start].type!=T_INT)    error("Illegal alpha argument to %s\n",name);    else -  +  {    img->alpha=sp[3-args+args_start].u.integer; -  +  return 4; +  }    else -  +  {    img->alpha=0; -  +  return 3;    } -  + }    -  +    /*** end internals ***/         void img_clear(rgb_group *dest,rgb_group rgb,INT32 size)   {    if(!size) return;    THREADS_ALLOW();    if(!rgb.r && !rgb.b && !rgb.g)    MEMSET(dest, 0, size*sizeof(rgb_group));    else if((sizeof(rgb.r) == 1) && (rgb.r == rgb.b && rgb.b == rgb.g))
pike.git/src/modules/Image/blit.c:264:   **! image to paste (may be empty, needs to be an image object)   **! arg int x   **! arg int y   **! where to paste the image; default is 0,0   **!   **! see also: paste_mask, paste_alpha, paste_alpha_color   */      void image_paste(INT32 args)   { -  struct image *img; +  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");    if (!THIS->img) return;       if (!img->img) return;   
pike.git/src/modules/Image/blit.c:497:       pop_n_elems(args);    ref_push_object(THISOBJ);   }      /*   **! method object paste_alpha_color(object mask)   **! method object paste_alpha_color(object mask,int x,int y)   **! method object paste_alpha_color(object mask,int r,int g,int b)   **! method object paste_alpha_color(object mask,int r,int g,int b,int x,int y) + **! method object paste_alpha_color(object mask,Color color) + **! method object paste_alpha_color(object mask,Color color,int x,int y)   **! Pastes a given color over the current image,   **! using the given mask as opaque channel.   **!   **! A pixel value of 255 makes the result become the color given,   **! 0 doesn't change anything.   **!   **! The masks red, green and blue values are used separately.   **! If no color are given, the current is used.   **!   **! returns the object called
pike.git/src/modules/Image/blit.c:528:   **! see also: paste_mask, paste_alpha, paste_alpha_color   */      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 && args!=4 && args!=6 && args!=3) -  error("illegal number of arguments to image->paste_alpha_color()\n"); +  if (args<1) +  error("too few arguments to image->paste_alpha_color()\n");    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");    if (!THIS->img) return;    if (!mask->img) return;    -  if (args==6 || args==4) /* colors at arg 2..4 */ -  getrgb(THIS,1,args,"image->paste_alpha_color()\n"); -  if (args==3) /* coords at 2..3 */ +  if (args==6 || args==4 || args==2 || args==3) /* color at arg 2.. */ +  arg=1+getrgb(THIS,1,args,"image->paste_alpha_color()\n"); +  if (args>arg+1)    { -  if (sp[1-args].type!=T_INT -  || sp[2-args].type!=T_INT) +  if (sp[arg-args].type!=T_INT +  || sp[arg-args].type!=T_INT)    error("illegal coordinate arguments to image->paste_alpha_color()\n"); -  x1=sp[1-args].u.integer; -  y1=sp[2-args].u.integer; +  x1=sp[arg-args].u.integer; +  y1=sp[arg-args].u.integer;    } -  else if (args==6) /* at 5..6 */ -  { -  if (sp[4-args].type!=T_INT -  || sp[5-args].type!=T_INT) -  error("illegal coordinate arguments to image->paste_alpha_color()\n"); -  x1=sp[4-args].u.integer; -  y1=sp[5-args].u.integer; -  } +     else x1=y1=0;       x2=MINIMUM(THIS->xsize-x1,mask->xsize);    y2=MINIMUM(THIS->ysize-y1,mask->ysize);      CHRONO("image_paste_alpha_color begin");       m=mask->img+MAXIMUM(0,-x1)+MAXIMUM(0,-y1)*mask->xsize;    d=THIS->img+MAXIMUM(0,-x1)+x1+(y1+MAXIMUM(0,-y1))*THIS->xsize;    x=MAXIMUM(0,-x1);