about summary refs log tree commit diff
path: root/editor/ppmdist.c
diff options
context:
space:
mode:
Diffstat (limited to 'editor/ppmdist.c')
-rw-r--r--editor/ppmdist.c29
1 files changed, 22 insertions, 7 deletions
diff --git a/editor/ppmdist.c b/editor/ppmdist.c
index 90c2e3d3..e8f17bff 100644
--- a/editor/ppmdist.c
+++ b/editor/ppmdist.c
@@ -22,6 +22,7 @@ struct colorToGrayEntry {
 #define MAXCOLORS 255
 
 
+
 static gray
 newGrayValue(pixel *pix, struct colorToGrayEntry *colorToGrayMap, int colors) {
 
@@ -40,20 +41,34 @@ newGrayValue(pixel *pix, struct colorToGrayEntry *colorToGrayMap, int colors) {
 
 
 
+#ifndef LITERAL_FN_DEF_MATCH
+static qsort_comparison_fn cmpColorToGrayEntryByIntensity;
+#endif
+
 static int
-cmpColorToGrayEntryByIntensity(const void *entry1, const void *entry2) {
+cmpColorToGrayEntryByIntensity(const void * const a,
+                               const void * const b) {
+
+    const struct colorToGrayEntry * const entry1P = a;
+    const struct colorToGrayEntry * const entry2P = b;
 
-    return ((struct colorToGrayEntry *) entry1)->gray -
-        ((struct colorToGrayEntry *) entry2)->gray;
+    return entry1P->gray - entry2P->gray;
 }
 
 
 
+#ifndef LITERAL_FN_DEF_MATCH
+static qsort_comparison_fn cmpColorToGrayEntryByFrequency;
+#endif
+
 static int
-cmpColorToGrayEntryByFrequency(const void * entry1, const void * entry2) {
+cmpColorToGrayEntryByFrequency(const void * const a,
+                               const void * const b) {
+
+    const struct colorToGrayEntry * const entry1P = a;
+    const struct colorToGrayEntry * const entry2P = b;
 
-    return ((struct colorToGrayEntry *) entry1)->frequency -
-        ((struct colorToGrayEntry *) entry2)->frequency;
+    return entry1P->frequency - entry2P->frequency;
 }
 
 
@@ -125,7 +140,7 @@ main(int argc, char *argv[]) {
          * by frequency - but again, for a small number of colors
          * it's a small matter.
          */
-        colorToGrayMap[color].gray = PPM_LUMIN(hist[color].color);
+        colorToGrayMap[color].gray = ppm_luminosity(hist[color].color);
     }
 
     /*