#include #include 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; }