1 | | |
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
28 | | |
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
70 | | |
71 | | |
72 | | |
73 | | |
74 | | |
75 | | |
76 | | |
77 | | |
78 | | |
79 | | |
80 | | |
81 | | |
82 | | |
83 | | |
84 | | |
85 | | |
86 | | |
87 | | |
88 | | |
89 | | |
90 | | |
91 | | |
92 | | |
93 | | |
94 | | |
95 | | |
96 | | |
97 | | |
| | | | | | | | | | | | | void IMAGE_PHASE(INT32 args) | { | struct object *o; | struct image *img, | *this; | rgb_group *imgi=0,*thisi=0; | | int y, x; | int yz, xz; | int ys, xs; | | if (!THIS->img) { Pike_error("no image\n"); return; } | this=THIS; | thisi=this->img; | | | push_int(this->xsize); | push_int(this->ysize); | o=clone_object(image_program,2); | img=(struct image*)get_storage(o,image_program); | imgi=img->img; | | pop_n_elems(args); | | THREADS_ALLOW(); | xz=this->xsize; | yz=this->ysize; | | xs=this->xsize-1; | ys=this->ysize-1; | | | #define DALOOP(R) \ | for(y=1; y<ys; y++) \ | for(x=1; x<xs; x++) \ | {\ | int i;\ | int V,H;\ | i=y*xs+x;\ | V=thisi[i-(NEIG)].R-thisi[i].R;\ | H=thisi[i+(NEIG)].R-thisi[i].R;\ | if ((V==0)&&(H==0))\ | {\ | /*\ | In this case a check to see what there are at the sides \ | should be done\ | */\ | imgi[i].R=0;\ | }\ | else \ | {\ | if (V==0) imgi[i].R=32;\ | else if (H==0) imgi[i].R=256-32;\ | else\ | {\ | if (abs(V)>abs(H))\ | if (V<0)\ | imgi[i].R=DOUBLE_TO_CHAR(0.5+224+(((float)H)/\ | (0-V))*32.0);\ | else\ | imgi[i].R=DOUBLE_TO_CHAR(0.5+96+(((float)H)/\ | (V))*32.0);\ | else\ | if (H<0)\ | imgi[i].R=DOUBLE_TO_CHAR(0.5+32+(((float)V)/\ | (0-H))*32.0);\ | else\ | imgi[i].R=DOUBLE_TO_CHAR(0.5+160+(((float)V)/\ | (H))*32.0);\ | }\ | }\ | } | | DALOOP(r) | DALOOP(g) | DALOOP(b) | | #undef DALOOP | | THREADS_DISALLOW(); | | ref_push_object(o); | } | | |
|