about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2015-06-28 02:10:57 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2015-06-28 02:10:57 +0000
commit9d9d6bdb744fb65ea153a723fd2e2768e193ae36 (patch)
treec101182537677f84078c8f3bf8ebe73cd66f64c1
parent9eb96613ada244d5d2314838f070acd4f4762872 (diff)
downloadnetpbm-mirror-9d9d6bdb744fb65ea153a723fd2e2768e193ae36.tar.gz
netpbm-mirror-9d9d6bdb744fb65ea153a723fd2e2768e193ae36.tar.xz
netpbm-mirror-9d9d6bdb744fb65ea153a723fd2e2768e193ae36.zip
cleanup
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2567 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--converter/other/pngx.c47
-rw-r--r--converter/other/pngx.h16
-rw-r--r--converter/other/pnmtopng.c7
3 files changed, 60 insertions, 10 deletions
diff --git a/converter/other/pngx.c b/converter/other/pngx.c
index 8d7b7c70..c9f6c7e9 100644
--- a/converter/other/pngx.c
+++ b/converter/other/pngx.c
@@ -322,6 +322,45 @@ pngx_setChrm(struct pngx *      const pngxP,
 
 
 
+const char *
+pngx_srgbIntentDesc(pngx_srgbIntent const srgbIntent) {
+
+    switch (srgbIntent) {
+    case PNGX_PERCEPTUAL:            return "PERCEPTUAL";
+    case PNGX_RELATIVE_COLORIMETRIC: return "RELATIVE COLORIMETRIC";
+    case PNGX_SATURATION:            return "SATURATION";
+    case PNGX_ABSOLUTE_COLORIMETRIC: return "ABSOLUTE_COLORIMETRIC";
+    }
+    assert(false);
+}
+
+
+
+static int
+const libpngSrgbIntentCode(pngx_srgbIntent const srgbIntent) {
+
+    switch (srgbIntent) {
+    case PNGX_PERCEPTUAL:            return 0;
+    case PNGX_RELATIVE_COLORIMETRIC: return 1;
+    case PNGX_SATURATION:            return 2;
+    case PNGX_ABSOLUTE_COLORIMETRIC: return 3;
+    }
+
+    assert(false);  /* All cases above return */
+}
+
+
+
+void
+pngx_setSrgb(struct pngx *   const pngxP,
+             pngx_srgbIntent const srgbIntent) {
+
+    png_set_sRGB(pngxP->png_ptr, pngxP->info_ptr,
+                 libpngSrgbIntentCode(srgbIntent));
+}
+
+
+
 void
 pngx_setCompressionSize(struct pngx * const pngxP,
                         unsigned int  const bufferSize) {
@@ -476,13 +515,13 @@ pngx_setText(struct pngx * const pngxP,
 
 void
 pngx_setTime(struct pngx * const pngxP,
-             png_time      const timeArg) {
+             time_t        const timeArg) {
 
-    png_time time;
+    png_time pngTime;
 
-    time = timeArg;
+    png_convert_from_time_t(&pngTime, timeArg);
 
-    png_set_tIME(pngxP->png_ptr, pngxP->info_ptr, &time);
+    png_set_tIME(pngxP->png_ptr, pngxP->info_ptr, &pngTime);
 }
 
 
diff --git a/converter/other/pngx.h b/converter/other/pngx.h
index 10e8204d..1252e32a 100644
--- a/converter/other/pngx.h
+++ b/converter/other/pngx.h
@@ -128,6 +128,20 @@ void
 pngx_setChrm(struct pngx *      const pngxP,
              struct pngx_chroma const chroma);
 
+typedef enum {
+    PNGX_PERCEPTUAL,
+    PNGX_RELATIVE_COLORIMETRIC,
+    PNGX_SATURATION,
+    PNGX_ABSOLUTE_COLORIMETRIC
+} pngx_srgbIntent;
+
+const char *
+pngx_srgbIntentDesc(pngx_srgbIntent const srgbIntent);
+
+void
+pngx_setSrgb(struct pngx *   const pngxP,
+             pngx_srgbIntent const srgbIntent);
+
 void
 pngx_setCompressionSize(struct pngx * const pngxP,
                         unsigned int  const bufferSize);
@@ -196,7 +210,7 @@ pngx_setText(struct pngx * const pngxP,
 
 void
 pngx_setTime(struct pngx * const pngxP,
-             png_time      const time);
+             time_t        const timeArg);
 
 void
 pngx_setTrnsPalette(struct pngx *    const pngxP,
diff --git a/converter/other/pnmtopng.c b/converter/other/pnmtopng.c
index 154ca279..38a6597b 100644
--- a/converter/other/pnmtopng.c
+++ b/converter/other/pnmtopng.c
@@ -2460,11 +2460,8 @@ static void
 doTimeChunk(struct cmdlineInfo const cmdline,
             struct pngx *      const pngxP) {
 
-    if (cmdline.modtimeSpec) {
-        png_time pngTime;
-        png_convert_from_time_t(&pngTime, cmdline.modtime);
-        pngx_setTime(pngxP, pngTime);
-    }
+    if (cmdline.modtimeSpec)
+        pngx_setTime(pngxP, cmdline.modtime);
 }