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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.10 1997/05/29 19:37:11 mirar Exp $ */ + /* $Id: blit.c,v 1.11 1997/09/01 01:35:32 per Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.10 1997/05/29 19:37:11 mirar Exp $<br> + **! $Id: blit.c,v 1.11 1997/09/01 01:35:32 per Exp $<br>   **! 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:253:    if (args>=3)    {    if (sp[1-args].type!=T_INT    || sp[2-args].type!=T_INT)    error("illegal 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); +  THISOBJ->refs++; +  push_object(THISOBJ); +  return; +  }    x2=x1+img->xsize-1;    y2=y1+img->ysize-1;    -  +  if(x2 < 0 || y2 < 0) /* Per */ +  { +  pop_n_elems(args); +  THISOBJ->refs++; +  push_object(THISOBJ); +  return; +  }    blitwidth=min(x2,THIS->xsize-1)-max(x1,0)+1;    blitheight=min(y2,THIS->ysize-1)-max(y1,0)+1;       img_blit(THIS->img+max(0,x1)+(THIS->xsize)*max(0,y1),    img->img+max(0,-x1)+(x2-x1+1)*max(0,-y1),    blitwidth,    blitheight,    THIS->xsize,    img->xsize);   
pike.git/src/modules/Image/blit.c:321:    if (args>=4)    {    if (sp[2-args].type!=T_INT    || sp[3-args].type!=T_INT)    error("illegal arguments to image->paste_alpha()\n");    x1=sp[2-args].u.integer;    y1=sp[3-args].u.integer;    }    else x1=y1=0;    - /* tråda här nåndag */ -  -  for (x=0; x<img->xsize; x++) -  for (y=0; y<img->ysize; y++) +  if(x1 >= THIS->xsize || y1 >= THIS->ysize) /* Per */    { -  THIS->rgb=pixel(img,x,y); -  setpixel_test(x1+x,y1+y); +  pop_n_elems(args); +  THISOBJ->refs++; +  push_object(THISOBJ); +  return;    }    -  + /* tråda här nåndag.. Ok /Per */ +  +  { +  rgb_group *source = img->img; +  struct image *this = THIS; +  int xs = this->xsize, ix, mx=img->xsize, my=img->ysize, x; +  int ys = this->ysize, iy, y; +  +  THREADS_ALLOW(); +  for (iy=0; iy<my; iy++) +  for (ix=0; ix<mx; ix++) +  { +  x = ix + x1; y = iy + y1; +  if(x>=0 && y>=0 && x<xs && y<ys) +  if(this->alpha) +  set_rgb_group_alpha(this->img[x+y*xs],*(source),this->alpha); +  else +  this->img[x+y*xs]=*(source); +  source++; +  } +  THREADS_DISALLOW(); +  }    pop_n_elems(args);    THISOBJ->refs++;    push_object(THISOBJ);   }      /*   **! method object paste_mask(object image,object mask)   **! method object paste_mask(object image,object mask,int x,int y)   **! Pastes a given image over the current image,   **! using the given mask as opaque channel.