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

version» Context lines:

pike.git/src/modules/Image/orient.c:1: - /* $Id: orient.c,v 1.18 2000/12/01 08:10:02 hubbe Exp $ */ + /* + || 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. + */      /*   **! module Image - **! note - **! $Id: orient.c,v 1.18 2000/12/01 08:10:02 hubbe Exp $ +    **! class Image   */      #include "global.h"      #include <math.h>   #include <ctype.h>    - #include "stralloc.h" - #include "global.h" +    #include "pike_macros.h"   #include "object.h" - #include "constants.h" +    #include "interpret.h"   #include "svalue.h"   #include "threads.h" - #include "array.h" +    #include "pike_error.h"      #include "image.h"      #include <builtin_functions.h>    - /* This must be included last! */ - #include "module_magic.h" +     -  + #define sp Pike_sp +    extern struct program *image_program;   #ifdef THIS   #undef THIS /* Needed for NT */   #endif   #define THIS ((struct image *)(Pike_fp->current_storage))   #define THISOBJ (Pike_fp->current_object)      #define testrange(x) MAXIMUM(MINIMUM((x),255),0)      static const double c0=0.70710678118654752440;
pike.git/src/modules/Image/orient.c:60:    + r.ru_utime.tv_usec-rold.ru_utime.tv_usec)    );       rold=r;   }   #else   #define CHRONO(X)   #endif      /* - **! method object orient(void|array(object)) + **! method object orient(void|array(object) something)   **! method array(object) orient4()   **! Draws images describing the orientation   **! of the current image.   **!   **! <tt>orient</tt> gives an HSV image   **! (run a <ref>hsv_to_rgb</ref> pass on it   **! to get a viewable image).   **! corresponding to the angle of the   **! orientation:   **! <pre> | / - \
pike.git/src/modules/Image/orient.c:94:   **! returns an image or an array of the four new image objects   **!   **! note   **! experimental status; may not be exact the same   **! output in later versions   */   static INLINE int sq(int a) { return a*a; }   static INLINE int my_abs(int a) { return (a<0)?-a:a; }      static void _image_orient(struct image *source, -  struct object *o[4], -  struct image *img[4]) +  struct object *o[5], +  struct image *img[5])   {    int i;    struct { int x,y; } or[4]={ {1,0}, {1,1}, {0,1}, {-1,1} };    int x,y;       for (i=0; i<5; i++)    {    push_int(source->xsize);    push_int(source->ysize);    o[i]=clone_object(image_program,2);
pike.git/src/modules/Image/orient.c:161:    rgb_group *d,*s1,*s2,*s3,*s0;    double mag;    int i, w, h;       if (!THIS->img) { Pike_error("Called Image.Image object is not initialized\n");; return; }       this=THIS;       if (args)    { -  if (sp[-args].type==T_INT) +  if (TYPEOF(sp[-args]) == T_INT)    mag=sp[-args].u.integer; -  else if (sp[-args].type==T_FLOAT) +  else if (TYPEOF(sp[-args]) == T_FLOAT)    mag=sp[-args].u.float_number;    else {    bad_arg_error("image->orient\\n",sp-args,args,1,"",sp+1-1-args,    "Bad argument 1 to image->orient\n()\n");    /* Not reached, but keeps the compiler happy. */    mag = 0.0;    }    }    else mag=1.0;       if (args==1)    pop_n_elems(args);       if (args>1)    { -  if (sp[1-args].type!=T_ARRAY) +  if (TYPEOF(sp[1-args]) != T_ARRAY)    bad_arg_error("image->orient\\n",sp-args,args,2,"",sp+2-1-args,    "Bad argument 2 to image->orient\n()\n");    if (sp[1-args].u.array->size!=4)    Pike_error("The array given as argument 2 to image->orient do not have size 4\n");    for(i=0; i<4; i++) -  if ((sp[1-args].u.array->item[i].type!=T_OBJECT) || +  if ((TYPEOF(sp[1-args].u.array->item[i]) != T_OBJECT) ||    (!(sp[1-args].u.array->item[i].u.object)) ||    (sp[1-args].u.array->item[i].u.object->prog!=image_program))    Pike_error("The array given as argument 2 to image->orient do not contain images\n");    img1=(struct image*)sp[1-args].u.array->item[0].u.object->storage;       w=this->xsize;    h=this->ysize;       for(i=0; i<4; i++)    {
pike.git/src/modules/Image/orient.c:262:    s0++;    s1++;    s2++;    s3++;    }   CHRONO("end hsv...");   THREADS_DISALLOW();       if (!w)    { -  o[4]->refs++; +  add_ref(o[4]);    pop_n_elems(5);    push_object(o[4]);    }   }         void image_orient4(INT32 args)   {    struct object *o[5];    struct image *img[5];       if (!THIS->img) { Pike_error("Called Image.Image object is not initialized\n");; return; }       pop_n_elems(args);    _image_orient(THIS,o,img);       pop_n_elems(1);    f_aggregate(4);   } -  +