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

version» Context lines:

pike.git/src/modules/Image/blit.c:1: - /* $Id: blit.c,v 1.5 1997/03/25 06:59:06 mirar Exp $ */ + /* $Id: blit.c,v 1.6 1997/04/03 07:00:08 mirar Exp $ */   #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"   #include "types.h"   #include "pike_macros.h"   #include "object.h"
pike.git/src/modules/Image/blit.c:549:   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<0||y2<0||x1>=THIS->xsize||y1>=THIS->ysize) return;    img_box_nocheck(max(x1,0),max(y1,0),min(x2,THIS->xsize-1),min(y2,THIS->ysize-1));   }         /* - **! method object add_layers(array(array(int|object)) layers) - **! method object add_layers(array(array(int|object)) layers,int x1,int y1,int x2,int y2) + **! method object add_layers(array(int|object)) layer0,...) + **! method object add_layers(int x1,int y1,int x2,int y2,array(int|object)) layer0,...)   **! Using the called object as base, adds layers using masks,   **! opaque channel values and special methods.   **!   **! The destination image can also be cropped, thus   **! speeding up the process.   **!   **! Each array in the layers array is one of:   **! <pre>   **! ({object image,object|int mask})   **! ({object image,object|int mask,int opaque_value})
pike.git/src/modules/Image/blit.c:584:   **! 5 diff (`-)   **! </pre>   **! The layer image and the current source are calculated   **! through the given method and then pasted using the mask   **! and the opaque channel value.   **!   **! All given images must be the same size.   **!   **! returns a new image object   **! - **! object image + **! arg array(int|object) layer0   **! image to paste - **! object mask - **! mask image - **! int x - **! int y - **! where to paste the image; default is 0,0 + **! arg int x1 + **! arg int y1 + **! arg int x2 + **! arg int y2 + **! rectangle for cropping   **!   **! see also: paste_mask, paste_alpha, paste_alpha_color, `|, `&, `*, `+, `-   */      void image_add_layers(INT32 args)   /*      [x1,y1,x2,y2],   ({object image,object mask|0,[int alpha_value,[int method]]}),   ({object image,object mask|0,[int alpha_value,[int method]]}),
pike.git/src/modules/Image/blit.c:679:    {    free(layer);    error("Illegal size of array argument to image->add_layers()\n");    }       if (a->item[0].type!=T_OBJECT    || !a->item[0].u.object    || a->item[0].u.object->prog!=image_program)    {    free(layer); -  error("Illegal array contents (wrong or no image) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (wrong or no image) to image->add_layers()\n",layers-i,args-i+1);    }    img=(struct image*)a->item[0].u.object->storage;    if (!img->img    || img->xsize != THIS->xsize    || img->ysize != THIS->ysize)    {    free(layer); -  error("Illegal array contents (no image or wrong image size) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (no image or wrong image size) to image->add_layers()\n",layers-i,args-i+1);    }    layer[j].s=img->img;       if (a->item[1].type==T_INT    && a->item[1].u.integer==0)    {    layer[j].m=NULL;    }    else    {    if (a->item[1].type!=T_OBJECT    || !a->item[1].u.object    || a->item[1].u.object->prog!=image_program)    {    free(layer); -  error("Illegal array contents (wrong or no image for mask) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (wrong or no image for mask) to image->add_layers()\n",layers-i,args-i+1);    }    img=(struct image*)a->item[1].u.object->storage;    if (!img->img    || img->xsize != THIS->xsize    || img->ysize != THIS->ysize)    {    free(layer); -  error("Illegal array contents (no mask or wrong mask size) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (no mask or wrong mask size) to image->add_layers()\n",layers-i,args-i+1);    }    layer[j].m=img->img;    }       if (a->size>=3)    {    if (a->item[2].type!=T_INT)    {    free(layer); -  error("Illegal array contents (illegal opaque) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (illegal opaque) to image->add_layers()\n",layers-i,args-i+1);    }    layer[j].opaque=a->item[2].u.integer;    }    else    layer[j].opaque=255;       if (a->size>=4)    {    if (a->item[3].type!=T_INT)    {    free(layer); -  error("Illegal array contents (illegal method) to image->add_layers()\n"); +  error("Illegal array contents, layer %d (argument %d) (illegal method) to image->add_layers()\n",layers-i,args-i+1);    }    layer[j].method=a->item[3].u.integer;    }    else    layer[j].method=LAYER_NOP;    }    -  pop_n_elems(args); -  +     push_int(1+x2-x1);    push_int(1+y2-y1);    o=clone_object(image_program,2);    d=((struct image*)(o->storage))->img;          mod=THIS->xsize-(x2-x1+1);    s+=x1+THIS->xsize*y1;    for (i=0; i<layers; i++)    {
pike.git/src/modules/Image/blit.c:818:   #define ALL_HAVE_MASK   #include "blit_layer_include.h"   #undef ALL_HAVE_MASK    }    else    {   #include "blit_layer_include.h"    }       +  pop_n_elems(args); +     free(layer);       push_object(o);   }