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

version» Context lines:

pike.git/src/modules/Image/layers.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: layers.c,v 1.82 2002/10/21 17:06:14 marcus Exp $ + || $Id: layers.c,v 1.83 2004/02/03 17:12:12 anders Exp $   */      /*   **! module Image   **! class Layer   **! see also: layers   **!      **!   **!
pike.git/src/modules/Image/layers.c:194:   **! return 0;   **! }   **!   **! </execute>   */      #include "global.h"      #include <math.h> /* floor */    - RCSID("$Id: layers.c,v 1.82 2002/10/21 17:06:14 marcus Exp $"); + RCSID("$Id: layers.c,v 1.83 2004/02/03 17:12:12 anders Exp $");      #include "image_machine.h"      #include "stralloc.h"   #include "pike_macros.h"   #include "object.h"   #include "constants.h"   #include "interpret.h"   #include "svalue.h"   #include "array.h"
pike.git/src/modules/Image/layers.c:2894:   **! method Image.Layer lay(array(Image.Layer|mapping) layers)   **! method Image.Layer lay(array(Image.Layer|mapping) layers,int xoffset,int yoffset,int xsize,int ysize)   **! Combine layers.   **! returns a new layer object.   **!   **! see also: Image.Layer   */      void image_lay(INT32 args)   { -  int layers,i; +  int layers,i,j;    struct layer **l;    struct object *o;    struct layer *dest;    struct array *a;    INT_TYPE xoffset=0,yoffset=0,xsize=0,ysize=0;       if (!args)    SIMPLE_TOO_FEW_ARGS_ERROR("Image.lay",1);       if (Pike_sp[-args].type!=T_ARRAY)
pike.git/src/modules/Image/layers.c:2929:       if (!layers) /* dummy return empty layer */    {    pop_n_elems(args);    push_object(clone_object(image_layer_program,0));    return;    }       l=(struct layer**)xalloc(sizeof(struct layer)*layers);    -  for (i=0; i<layers; i++) +  for (i=j=0; i<layers; i++)    {    if (a->item[i].type==T_OBJECT)    { -  if (!(l[i]=(struct layer*)get_storage(a->item[i].u.object, +  if (!(l[j]=(struct layer*)get_storage(a->item[i].u.object,    image_layer_program)))    SIMPLE_BAD_ARG_ERROR("Image.lay",1,    "array(Image.Layer|mapping)");    }    else if (a->item[i].type==T_MAPPING)    {    push_svalue(a->item+i);    push_object(o=clone_object(image_layer_program,1));    args++; -  l[i]=(struct layer*)get_storage(o,image_layer_program); +  l[j]=(struct layer*)get_storage(o,image_layer_program);    }    else    SIMPLE_BAD_ARG_ERROR("Image.lay",1,    "array(Image.Layer|mapping)"); -  +  if (l[j]->xsize && l[j]->ysize) { +  j++;    } -  +  }    -  +  if (!(layers = j)) /* dummy return empty layer */ +  { +  free(l); +  pop_n_elems(args); +  push_object(clone_object(image_layer_program,0)); +  return; +  } +     if (xsize==0) /* figure offset and size */    {    xoffset=l[0]->xoffs;    yoffset=l[0]->yoffs;    xsize=l[0]->xsize;    ysize=l[0]->ysize;    if (l[0]->tiled) /* set size from the first non-tiled */    {    for (i=1; i<layers; i++)    if (!l[i]->tiled)