summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore2
-rw-r--r--src/pnmlcms.c77
2 files changed, 78 insertions, 1 deletions
diff --git a/.hgignore b/.hgignore
index 47a7094..af2979d 100644
--- a/.hgignore
+++ b/.hgignore
@@ -22,4 +22,4 @@ install-sh
stamp-h1
missing
tags
-flimsel
+pnmlcms
diff --git a/src/pnmlcms.c b/src/pnmlcms.c
new file mode 100644
index 0000000..1fe231b
--- /dev/null
+++ b/src/pnmlcms.c
@@ -0,0 +1,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;
+}
+
+
+