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

version» Context lines:

pike.git/src/modules/Image/orient.c:1: - /* $Id: orient.c,v 1.12 1999/06/18 19:19:28 mirar Exp $ */ + /* $Id: orient.c,v 1.13 1999/06/19 20:24:48 hubbe Exp $ */      /*   **! module Image   **! note - **! $Id: orient.c,v 1.12 1999/06/18 19:19:28 mirar Exp $ + **! $Id: orient.c,v 1.13 1999/06/19 20:24:48 hubbe Exp $   **! class Image   */      #include "global.h"      #include <math.h>   #include <ctype.h>      #include "stralloc.h"   #include "global.h"
pike.git/src/modules/Image/orient.c:88:   **! 4 image objects, corresponding to the   **! amount of different directions, see above.   **!   **! 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 abs(int a) { return (a<0)?-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])   {    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++)
pike.git/src/modules/Image/orient.c:125:    int xd=or[i].x;    int yd=or[i].y;       for(x=1; x<xz-1; x++)    for(y=1; y<yz-1; y++)    {   #define FOOBAR(CO) \    d[x+y*xz].CO \    = \    (COLORTYPE) \ -  abs( s[(x+xd)+(y+yd)*xz].CO - s[(x-xd)+(y-yd)*xz].CO ) +  my_abs( s[(x+xd)+(y+yd)*xz].CO - s[(x-xd)+(y-yd)*xz].CO )       /*    sqrt( ( sq( s[(x-xd)+(y-yd)*xz].CO - s[x+y*xz].CO ) + \    sq( s[(x+xd)+(y+yd)*xz].CO - s[x+y*xz].CO ) ) / 2.0 )    */       FOOBAR(r);    FOOBAR(g);    FOOBAR(b);   
pike.git/src/modules/Image/orient.c:233:    {    /* Första färg, sista mörkhet */    float j=(s0->r+s0->g+s0->b-s2->r-s2->g-s2->b)/3.0;    /* riktning - - riktning | */       float h=(s1->r+s1->g+s1->b-s3->r-s3->g-s3->b)/3.0;    /* riktning \ - riktning / */       int z,w;    -  if (abs(h)>abs(j)) -  if (h) z=-(int)(32*(j/h)+(h>0)*128+64),w=abs(h); +  if (my_abs(h)>my_abs(j)) +  if (h) z=-(int)(32*(j/h)+(h>0)*128+64),w=my_abs(h);    else z=0,w=0;    else -  z=-(int)(-32*(h/j)+(j>0)*128+128),w=abs(j); +  z=-(int)(-32*(h/j)+(j>0)*128+128),w=my_abs(j);       d->r=(COLORTYPE)z;    d->g=255;    d->b=(COLORTYPE)MINIMUM(w*mag,255);       d++;    s0++;    s1++;    s2++;    s3++;