Initial revision
[imager.git] / trans2.c
CommitLineData
02d1d628
AMH
1#include "image.h"
2#include "regmach.h"
3
4i_img* i_transform2(int width, int height, int channels,
5 struct rm_op *ops, int ops_count,
6 double *n_regs, int n_regs_count,
7 i_color *c_regs, int c_regs_count,
8 i_img **in_imgs, int in_imgs_count)
9{
10 i_img *new_img;
11 int x, y;
12 i_color val;
13 int i;
14
15 /* since the number of images is variable and the image numbers
16 for getp? are fixed, we can check them here instead of in the
17 register machine - this will help performance */
18 for (i = 0; i < ops_count; ++i) {
19 switch (ops[i].code) {
20 case rbc_getp1:
21 case rbc_getp2:
22 case rbc_getp3:
23 if (ops[i].code - rbc_getp1 + 1 > in_imgs_count) {
24 /* Foo */
25 return NULL;
26 }
27 }
28 }
29
30 new_img = i_img_empty_ch(NULL, width, height, channels);
31 for (x = 0; x < width; ++x) {
32 for (y = 0; y < height; ++y) {
33 n_regs[0] = x;
34 n_regs[1] = y;
35 val = rm_run(ops, ops_count, n_regs, n_regs_count, c_regs, c_regs_count,
36 in_imgs, in_imgs_count);
37 i_ppix(new_img, x, y, &val);
38 }
39 }
40
41 return new_img;
42}