|
18 | 18 |
|
19 | 19 | #include "Imaging.h" |
20 | 20 |
|
| 21 | +// restrict safety: imIn1/imIn2 are read-only, and imOut is always freshly allocated |
21 | 22 | #define CHOP(operation) \ |
22 | 23 | int x, y; \ |
23 | 24 | Imaging imOut; \ |
24 | 25 | imOut = create(imIn1, imIn2, IMAGING_MODE_UNKNOWN); \ |
25 | 26 | if (!imOut) { \ |
26 | 27 | return NULL; \ |
27 | 28 | } \ |
28 | | - for (y = 0; y < imOut->ysize; y++) { \ |
29 | | - UINT8 *out = (UINT8 *)imOut->image[y]; \ |
30 | | - UINT8 *in1 = (UINT8 *)imIn1->image[y]; \ |
31 | | - UINT8 *in2 = (UINT8 *)imIn2->image[y]; \ |
32 | | - for (x = 0; x < imOut->linesize; x++) { \ |
| 29 | + int ysize = imOut->ysize; \ |
| 30 | + int linesize = imOut->linesize; \ |
| 31 | + for (y = 0; y < ysize; y++) { \ |
| 32 | + UINT8 *restrict out = (UINT8 *)imOut->image[y]; \ |
| 33 | + UINT8 *restrict in1 = (UINT8 *)imIn1->image[y]; \ |
| 34 | + UINT8 *restrict in2 = (UINT8 *)imIn2->image[y]; \ |
| 35 | + for (x = 0; x < linesize; x++) { \ |
33 | 36 | int temp = operation; \ |
34 | 37 | if (temp <= 0) { \ |
35 | 38 | out[x] = 0; \ |
|
42 | 45 | } \ |
43 | 46 | return imOut; |
44 | 47 |
|
45 | | -#define CHOP2(operation, mode) \ |
46 | | - int x, y; \ |
47 | | - Imaging imOut; \ |
48 | | - imOut = create(imIn1, imIn2, mode); \ |
49 | | - if (!imOut) { \ |
50 | | - return NULL; \ |
51 | | - } \ |
52 | | - for (y = 0; y < imOut->ysize; y++) { \ |
53 | | - UINT8 *out = (UINT8 *)imOut->image[y]; \ |
54 | | - UINT8 *in1 = (UINT8 *)imIn1->image[y]; \ |
55 | | - UINT8 *in2 = (UINT8 *)imIn2->image[y]; \ |
56 | | - for (x = 0; x < imOut->linesize; x++) { \ |
57 | | - out[x] = operation; \ |
58 | | - } \ |
59 | | - } \ |
| 48 | +// restrict safety: imIn1/imIn2 are read-only, and imOut is always freshly allocated |
| 49 | +#define CHOP2(operation, mode) \ |
| 50 | + int x, y; \ |
| 51 | + Imaging imOut; \ |
| 52 | + imOut = create(imIn1, imIn2, mode); \ |
| 53 | + if (!imOut) { \ |
| 54 | + return NULL; \ |
| 55 | + } \ |
| 56 | + int ysize = imOut->ysize; \ |
| 57 | + int linesize = imOut->linesize; \ |
| 58 | + for (y = 0; y < ysize; y++) { \ |
| 59 | + UINT8 *restrict out = (UINT8 *)imOut->image[y]; \ |
| 60 | + UINT8 *restrict in1 = (UINT8 *)imIn1->image[y]; \ |
| 61 | + UINT8 *restrict in2 = (UINT8 *)imIn2->image[y]; \ |
| 62 | + for (x = 0; x < linesize; x++) { \ |
| 63 | + out[x] = operation; \ |
| 64 | + } \ |
| 65 | + } \ |
60 | 66 | return imOut; |
61 | 67 |
|
62 | 68 | static Imaging |
|
0 commit comments