summaryrefslogtreecommitdiffstats
path: root/colour.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2008-10-09 22:00:33 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2008-10-09 22:00:33 +0000
commit0ba0fd389c211c35958a383cbaea138f6eebea91 (patch)
treeb50b85185977a0a30d63654fb30bd389af42ebb7 /colour.c
parent185f7297e8df1399094b7e3d1314f1af1e94e633 (diff)
Translate 256 colours to 16.
Diffstat (limited to 'colour.c')
-rw-r--r--colour.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/colour.c b/colour.c
index 36a2cf6f..552a220c 100644
--- a/colour.c
+++ b/colour.c
@@ -1,4 +1,4 @@
-/* $Id: colour.c,v 1.1 2008-09-10 18:59:29 nicm Exp $ */
+/* $Id: colour.c,v 1.2 2008-10-09 22:00:33 nicm Exp $ */
/*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -72,3 +72,28 @@ colour_fromstring(const char *s)
return (8);
return (255);
}
+
+u_char
+colour_translate256(u_char c)
+{
+ static const u_char table[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 0, 4, 4, 4, 12, 12, 2, 6, 4, 4, 12, 12, 2, 2, 6, 4,
+ 12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10,
+ 10, 10, 10, 14, 1, 5, 4, 4, 12, 12, 3, 8, 4, 4, 12, 12,
+ 2, 2, 6, 4, 12, 12, 2, 2, 2, 6, 12, 12, 10, 10, 10, 10,
+ 14, 12, 10, 10, 10, 10, 10, 14, 1, 1, 5, 4, 12, 12, 1, 1,
+ 5, 4, 12, 12, 3, 3, 8, 4, 12, 12, 2, 2, 2, 6, 12, 12,
+ 10, 10, 10, 10, 14, 12, 10, 10, 10, 10, 10, 14, 1, 1, 1, 5,
+ 12, 12, 1, 1, 1, 5, 12, 12, 1, 1, 1, 5, 12, 12, 3, 3,
+ 3, 7, 12, 12, 10, 10, 10, 10, 14, 12, 10, 10, 10, 10, 10, 14,
+ 9, 9, 9, 9, 13, 12, 9, 9, 9, 9, 13, 12, 9, 9, 9, 9,
+ 13, 12, 9, 9, 9, 9, 13, 12, 11, 11, 11, 11, 7, 12, 10, 10,
+ 10, 10, 10, 14, 9, 9, 9, 9, 9, 13, 9, 9, 9, 9, 9, 13,
+ 9, 9, 9, 9, 9, 13, 9, 9, 9, 9, 9, 13, 9, 9, 9, 9,
+ 9, 13, 11, 11, 11, 11, 11, 15, 0, 0, 0, 0, 0, 0, 8, 8,
+ 8, 8, 8, 8, 7, 7, 7, 7, 7, 7, 15, 15, 15, 15, 15, 15
+ };
+
+ return (table[c]);
+}