diff options
| author | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2007-10-03 22:13:09 +0200 |
|---|---|---|
| committer | Johannes Hofmann <Johannes.Hofmann@gmx.de> | 2007-10-03 22:13:09 +0200 |
| commit | f7b56c6ff7f78a68aff10e98365058ea857a371f (patch) | |
| tree | cb1cd8b1ef948fe5dfc44b7a4834061a6a4f6328 /src | |
| parent | d863b28dd3cc6f5e3d025f4fb0de80fbe82023a3 (diff) | |
add initial gamma support
Diffstat (limited to 'src')
| -rw-r--r-- | src/pnmlcms.c | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/src/pnmlcms.c b/src/pnmlcms.c index 5c14d44..41b3047 100644 --- a/src/pnmlcms.c +++ b/src/pnmlcms.c @@ -6,13 +6,14 @@ pam_transform(struct pam *inpam, struct pam *outpam, cmsHTRANSFORM *hTransform); int main(int argc, char **argv) { - int c; + int c, i, nProf = 0; char *in_prof = NULL, *out_prof = NULL; + double gamma = 0.0; cmsHTRANSFORM hTransform; - cmsHPROFILE hInProfile, hOutProfile; + cmsHPROFILE profiles[3]; struct pam inpam, outpam; - while ((c = getopt(argc, argv, "i:o:")) != EOF) { + while ((c = getopt(argc, argv, "i:o:g:")) != EOF) { switch (c) { case 'i': in_prof = optarg; @@ -20,20 +21,46 @@ main(int argc, char **argv) { case 'o': out_prof = optarg; break; + case 'g': + gamma = atof(optarg); + break; default: break; } } - hInProfile = cmsOpenProfileFromFile(in_prof, "r"); - hOutProfile = cmsOpenProfileFromFile(out_prof, "r"); - hTransform = cmsCreateTransform(hInProfile, + if (in_prof) { + profiles[nProf++] = cmsOpenProfileFromFile(in_prof, "r"); + } else { + profiles[nProf++] = cmsCreate_sRGBProfile(); + } + + if (gamma) { + LPGAMMATABLE gTable[3]; + + gTable[0] = cmsBuildGamma(256, gamma); + gTable[1] = gTable[2] = cmsBuildGamma(256, 1.0); + + profiles[nProf++] = cmsCreateLinearizationDeviceLink( + icSigLabData, + gTable); + } + + if (out_prof) { + profiles[nProf++] = cmsOpenProfileFromFile(out_prof, "r"); + } else { + profiles[nProf++] = cmsCreate_sRGBProfile(); + } + + + hTransform = cmsCreateMultiprofileTransform( + profiles, + nProf, TYPE_RGB_16, - hOutProfile, TYPE_RGB_16, - INTENT_PERCEPTUAL, 0); - + INTENT_PERCEPTUAL, + 0); pm_init(argv[0], 0); @@ -46,8 +73,10 @@ main(int argc, char **argv) { pam_transform(&inpam, &outpam, &hTransform); cmsDeleteTransform(hTransform); - cmsCloseProfile(hInProfile); - cmsCloseProfile(hOutProfile); + + for (i = 0; i < nProf; i++) { + cmsCloseProfile(profiles[i]); + } return 0; } |
