line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#include "imager.h" |
2
|
|
|
|
|
|
|
#include "regmach.h" |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
/* |
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
trans2.c - entry point for the general transformation engine |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
int width, height, channels; |
12
|
|
|
|
|
|
|
struct rm_ops *ops; |
13
|
|
|
|
|
|
|
int op_count; |
14
|
|
|
|
|
|
|
double *n_regs; |
15
|
|
|
|
|
|
|
int n_regs_count; |
16
|
|
|
|
|
|
|
i_color *c_regs; |
17
|
|
|
|
|
|
|
int c_regs_count; |
18
|
|
|
|
|
|
|
i_img **in_imgs; |
19
|
|
|
|
|
|
|
int in_imgs_count; |
20
|
|
|
|
|
|
|
i_img *result = transform2(width, height, channels, ops, ops_count, |
21
|
|
|
|
|
|
|
n_regs, n_regs_count, c_regs, c_regs_count, |
22
|
|
|
|
|
|
|
in_imgs, in_imgs_count); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 DESCRIPTION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This (short) file implements the transform2() function, just iterating |
27
|
|
|
|
|
|
|
over the image - most of the work is done in L |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
*/ |
31
|
|
|
|
|
|
|
|
32
|
28
|
|
|
|
|
|
i_img* i_transform2(i_img_dim width, i_img_dim height, int channels, |
33
|
|
|
|
|
|
|
struct rm_op *ops, int ops_count, |
34
|
|
|
|
|
|
|
double *n_regs, int n_regs_count, |
35
|
|
|
|
|
|
|
i_color *c_regs, int c_regs_count, |
36
|
|
|
|
|
|
|
i_img **in_imgs, int in_imgs_count) |
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
i_img *new_img; |
39
|
|
|
|
|
|
|
i_img_dim x, y; |
40
|
|
|
|
|
|
|
i_color val; |
41
|
|
|
|
|
|
|
int i; |
42
|
|
|
|
|
|
|
int need_images; |
43
|
|
|
|
|
|
|
|
44
|
28
|
|
|
|
|
|
i_clear_error(); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
/* since the number of images is variable and the image numbers |
47
|
|
|
|
|
|
|
for getp? are fixed, we can check them here instead of in the |
48
|
|
|
|
|
|
|
register machine - this will help performance */ |
49
|
28
|
|
|
|
|
|
need_images = 0; |
50
|
207
|
100
|
|
|
|
|
for (i = 0; i < ops_count; ++i) { |
51
|
179
|
100
|
|
|
|
|
switch (ops[i].code) { |
52
|
|
|
|
|
|
|
case rbc_getp1: |
53
|
|
|
|
|
|
|
case rbc_getp2: |
54
|
|
|
|
|
|
|
case rbc_getp3: |
55
|
19
|
100
|
|
|
|
|
if (ops[i].code - rbc_getp1 + 1 > need_images) { |
56
|
18
|
|
|
|
|
|
need_images = ops[i].code - rbc_getp1 + 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
28
|
100
|
|
|
|
|
if (need_images > in_imgs_count) { |
62
|
1
|
|
|
|
|
|
i_push_errorf(0, "not enough images, code requires %d, %d supplied", |
63
|
|
|
|
|
|
|
need_images, in_imgs_count); |
64
|
1
|
|
|
|
|
|
return NULL; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
27
|
|
|
|
|
|
new_img = i_img_empty_ch(NULL, width, height, channels); |
68
|
891
|
100
|
|
|
|
|
for (x = 0; x < width; ++x) { |
69
|
181946
|
100
|
|
|
|
|
for (y = 0; y < height; ++y) { |
70
|
181082
|
|
|
|
|
|
n_regs[0] = x; |
71
|
181082
|
|
|
|
|
|
n_regs[1] = y; |
72
|
181082
|
|
|
|
|
|
val = i_rm_run(ops, ops_count, n_regs, n_regs_count, c_regs, c_regs_count, |
73
|
|
|
|
|
|
|
in_imgs, in_imgs_count); |
74
|
181082
|
|
|
|
|
|
i_ppix(new_img, x, y, &val); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
28
|
|
|
|
|
|
return new_img; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
/* |
82
|
|
|
|
|
|
|
=head1 AUTHOR |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Tony Cook |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 SEE ALSO |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Imager(3), regmach.c |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
91
|
|
|
|
|
|
|
*/ |