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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.27 1998/01/16 22:09:07 grubba Exp $ */ + /* $Id: blit.c,v 1.28 1998/04/20 18:53:27 grubba Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.27 1998/01/16 22:09:07 grubba Exp $ + **! $Id: blit.c,v 1.28 1998/04/20 18:53:27 grubba 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:289:    || 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); +  ref_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); +  ref_push_object(THISOBJ);    return;    }    blitwidth=MINIMUM(x2,THIS->xsize-1)-MAXIMUM(x1,0)+1;    blitheight=MINIMUM(y2,THIS->ysize-1)-MAXIMUM(y1,0)+1;       img_blit(THIS->img+MAXIMUM(0,x1)+(THIS->xsize)*MAXIMUM(0,y1),    img->img+MAXIMUM(0,-x1)+(x2-x1+1)*MAXIMUM(0,-y1),    blitwidth,    blitheight,    THIS->xsize,    img->xsize);       pop_n_elems(args); -  THISOBJ->refs++; -  push_object(THISOBJ); +  ref_push_object(THISOBJ);   }      /*   **! method object paste_alpha(object image,int alpha)   **! method object paste_alpha(object image,int alpha,int x,int y)   **! Pastes a given image over the current image, with   **! the specified alpha channel value.   **!   **! An alpha channel value of 0 leaves nothing of the original   **! image in the paste area, 255 is meaningless and makes the
pike.git/src/modules/Image/blit.c:369:    || 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;       if(x1 >= THIS->xsize || y1 >= THIS->ysize) /* Per */    {    pop_n_elems(args); -  THISOBJ->refs++; -  push_object(THISOBJ); +  ref_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;
pike.git/src/modules/Image/blit.c:398:    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); +  ref_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.   **!   **! A pixel value of 255 makes the result become a pixel   **! from the given image, 0 doesn't change anything.
pike.git/src/modules/Image/blit.c:495:    else if (m->b==0) {}    else d->b=(unsigned char)(((d->b*(255-m->b))+(s->b*m->b))*q);    s++; m++; d++;    }    s+=smod; m+=mmod; d+=dmod;    }    THREADS_DISALLOW();   CHRONO("image_paste_mask end");       pop_n_elems(args); -  THISOBJ->refs++; -  push_object(THISOBJ); +  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)   **! Pastes a given color over the current image,   **! using the given mask as opaque channel.   **!
pike.git/src/modules/Image/blit.c:602:    else if (m->b==0) ;    else d->b=(unsigned char)(((d->b*(255-m->b))+(rgb.b*m->b))*q);    m++; d++;    }    m+=mmod; d+=dmod;    }    THREADS_DISALLOW();   CHRONO("image_paste_alpha_color end");       pop_n_elems(args); -  THISOBJ->refs++; -  push_object(THISOBJ); +  ref_push_object(THISOBJ);   }      void img_box(INT32 x1,INT32 y1,INT32 x2,INT32 y2)   {    if (x1>x2) x1^=x2,x2^=x1,x1^=x2;    if (y1>y2) y1^=y2,y2^=y1,y1^=y2;    if (x2 >= THIS->xsize) x2 = THIS->xsize-1;    if (y2 >= THIS->ysize) y2 = THIS->ysize-1;    if (x2<0||y2<0||x1>=THIS->xsize||y1>=THIS->ysize) return;    if (x1<0) x1 = 0;