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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.49 2000/12/01 08:09:58 hubbe Exp $ */ + /* $Id: blit.c,v 1.50 2002/04/10 21:27:10 stewa Exp $ */   #include "global.h"      /*   **! module Image   **! note - **! $Id: blit.c,v 1.49 2000/12/01 08:09:58 hubbe Exp $ + **! $Id: blit.c,v 1.50 2002/04/10 21:27:10 stewa 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:202:   CHRONO("image_blit end");      }      void img_crop(struct image *dest,    struct image *img,    INT32 x1,INT32 y1,    INT32 x2,INT32 y2)   {    rgb_group *new; -  INT32 xp,yp,xs,ys; +  INT32 xp,yp,xs,ys,tmp;       if (dest->img) { free(dest->img); dest->img=NULL; }    -  if (x1>x2) x1^=x2,x2^=x1,x1^=x2; -  if (y1>y2) y1^=y2,y2^=y1,y1^=y2; +  if (x1>x2) tmp=x1, x1=x2, x2=tmp; +  if (y1>y2) tmp=y1, y1=y2, y2=tmp;       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)    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));
pike.git/src/modules/Image/blit.c:237:    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);    +  if( ! (( x2 < 0) || (y2 < 0) || (x1>=img->xsize) || (y1>=img->ysize))) { +     if (x1<0) x1=0; else if (x1>=img->xsize) x1=img->xsize-1;    if (y1<0) y1=0; else if (y1>=img->ysize) y1=img->ysize-1;    if (x2<0) x2=0; else if (x2>=img->xsize) x2=img->xsize-1;    if (y2<0) y2=0; else if (y2>=img->ysize) y2=img->ysize-1;       img_blit(new+xp+yp*dest->xsize,    img->img+xs+(img->xsize)*ys,    x2-x1+1,    y2-y1+1,    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) 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);