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
|
#include <pam.h>
#include <lcms.h>
static int
pam_transform(struct pam *inpam, struct pam *outpam, cmsHTRANSFORM *hTransform);
int
main(int argc, char **argv) {
int c;
char *in_prof = NULL, *out_prof = NULL;
cmsHTRANSFORM hTransform;
cmsHPROFILE hInProfile, hOutProfile;
struct pam inpam, outpam;
while ((c = getopt(argc, argv, "i:o:")) != EOF) {
switch (c) {
case 'i':
in_prof = optarg;
break;
case 'o':
out_prof = optarg;
break;
default:
break;
}
}
hInProfile = cmsOpenProfileFromFile(in_prof, "r");
hOutProfile = cmsOpenProfileFromFile(out_prof, "r");
hTransform = cmsCreateTransform(hInProfile,
TYPE_BGR_8,
hOutProfile,
TYPE_BGR_8,
INTENT_PERCEPTUAL, 0);
pm_init(argv[0], 0);
pnm_readpaminit(stdin, &inpam, PAM_STRUCT_SIZE(tuple_type));
outpam = inpam; outpam.file = stdout;
pnm_writepaminit(&outpam);
pam_transform(&inpam, &outpam, hTransform);
}
static int
pam_transform(struct pam *inpam, struct pam *outpam, cmsHTRANSFORM *hTransform)
{
tuple * tuplerow;
unsigned int row;
tuplerow = pnm_allocpamrow(inpam);
for (row = 0; row < inpam->height; row++) {
unsigned int column;
pnm_readpamrow(inpam, tuplerow);
for (column = 0; column < inpam->width; ++column) {
unsigned int plane;
for (plane = 0; plane < inpam->depth; ++plane) {
//grand_total += tuplerow[column][plane];
}
}
pnm_writepamrow(outpam, tuplerow);
}
pnm_freepamrow(tuplerow);
return 0;
}
|