]> granicus.if.org Git - graphviz/commitdiff
bug fixing
authorellson <devnull@localhost>
Wed, 1 Oct 2008 22:05:25 +0000 (22:05 +0000)
committerellson <devnull@localhost>
Wed, 1 Oct 2008 22:05:25 +0000 (22:05 +0000)
lib/inkpot/Makefile.old
lib/inkpot/inkpot_scheme.c
lib/inkpot/inkpot_value.c
lib/inkpot/inkpot_value.h

index 60e236395b867d13ff1ce3631471b8a9e895cc27..8ea5af8247b708770447bf82fc8dfb8020457c58 100644 (file)
@@ -21,7 +21,6 @@ inkpot_scheme_table.h: inkpot_define.h
 
 inkpot_define.h: scripts/lib-h.tcl       tk.lib svg.lib x11.lib 
        scripts/lib-h.tcl tk.lib svg.lib x11.lib
-       rm tk.lib svg.lib x11.lib
 
 x11.lib: scripts/rgb.txt-x11.lib.tcl     data/rgb.txt
        scripts/rgb.txt-x11.lib.tcl data/rgb.txt
index 55dabe7dd1e7bf65d7a1972d71bd066755de2f6c..c943077b1f54645572a4d902d8cf3e08fab55704 100644 (file)
@@ -372,15 +372,14 @@ inkpot_status_t inkpot_put_rgba ( inkpot_t *inkpot, double rgba[4] )
 {
     inkpot_status_t rc;
     inkpot_value_t value;
-    unsigned long v;
+    double v;
     int i;
 
     for (i = 0; i < 4; i++) {
-       value.value <<= 16;
        v = rgba[i];
        v = (v < 0.0) ? 0.0 : v;
        v = (v > 1.0) ? 1.0 : v;
-       value.value |= (int)(v * 65535);
+       value.value[i] = (unsigned short)(v * 65535);
     }
     value.vtype = VTYPE_rgba;
     
@@ -438,20 +437,18 @@ inkpot_status_t inkpot_put ( inkpot_t *inkpot, const char *color )
     if (*inkpot->canon == '#') {
        a = 65535;
         if ((len = sscanf(inkpot->canon, "#%4x%4x%4x%4x", &r, &g, &b, &a)) >= 3) {
-           value.value = (((((((unsigned long)r) << 16)
-                             | (unsigned long)g) << 16)
-                             | (unsigned long)b) << 16)
-                             | (unsigned long)a;
+           value.value[0] = r;
+           value.value[1] = g;
+           value.value[2] = b;
+           value.value[3] = a;
        }
        else if (len < 3) {
            a = 255;
            if ((len = sscanf(inkpot->canon, "#%2x%2x%2x%2x", &r, &g, &b, &a)) >= 3) {
-/*             r *= 65535/255; g *= 65535/255; b *= 65535/255; a *= 65535/255;   // too ugly */
-               value.value = (((((((unsigned long)r) << 16)
-                                 | (unsigned long)g) << 16)
-                                 | (unsigned long)b) << 16)
-                                 | (unsigned long)a;
-               value.value |= value.value << 8;                                  /* not ugly */
+               value.value[0] = r | r << 8;
+               value.value[1] = g | r << 8;
+               value.value[2] = b | r << 8;
+               value.value[3] = a | r << 8;
            } 
        }
        if (len >= 3) {
@@ -527,7 +524,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color )
     IDX_ALTS i;
     IDX_VALUES value_idx;
     int maybe;
-    
+
     /* FIXME - why isn't this checking the current value then the 4 level cache? */
     out_name = inkpot->out_name;
     if (out_name) {  /* if we have a cached name */
@@ -604,9 +601,8 @@ inkpot_status_t inkpot_get_rgba_i ( inkpot_t *inkpot, unsigned short rgba[4] )
     value = inkpot->value;
     rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
     if (rc == INKPOT_SUCCESS) {
-       for (i = 3; i >= 0; i--) {
-           rgba[i] = (value.value & 65535);
-           value.value >>= 16;
+       for (i = 0; i < 4; i++) {
+           rgba[i] = value.value[i];
        }
     }
     return rc;
@@ -621,9 +617,8 @@ inkpot_status_t inkpot_get_rgba ( inkpot_t *inkpot, double rgba[4] )
     value = inkpot->value;
     rc = inkpot->status = inkpot_value_get( &inkpot->values, &value );
     if (rc == INKPOT_SUCCESS) {
-       for (i = 3; i >= 0; i--) {
-           rgba[i] = (value.value & 65535) / (double)65535;
-           value.value >>= 16;
+       for (i = 0; i < 4; i++) {
+           rgba[i] = value.value[i] / (double)65535;
        }
     }
     return rc;
@@ -761,9 +756,12 @@ inkpot_status_t inkpot_debug_schemes( inkpot_t *inkpot )
            if (! found) {
                 inkpot_puts(inkpot, " ");
                 inkpot_puts(inkpot, &TAB_SCHEME_STRINGS[TAB_SCHEMES[i].string_idx]);
-                inkpot_puts(inkpot, "(out)");
+               found++;
            }
+            inkpot_puts(inkpot, "(out)");
         }
+       if (found) 
+           inkpot_puts(inkpot, "\n");
     }
     for (j = 0; j < inkpot->active_schemes; j++) {
         inkpot_puts(inkpot, " ");
index a0afb91532a9d39276ee489a80be630923d1fbd0..106f80bb16b8c791d439e9c9f0ee928009d46f93 100644 (file)
@@ -34,28 +34,27 @@ inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *valu
 inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *value )
 {
     IDX_VALUES_24 i;
+    unsigned short v;
 
     /* FIXME - this routine must check for 8 bit values and properly scale to 16 for the api */
 
     if (value->index < SZT_VALUES) {
        i = 3 * value->index;
 
-       value->value  = TAB_VALUES_24[i++] << 16;
-       value->value |= TAB_VALUES_24[i++] << 16;
-       value->value |= TAB_VALUES_24[i] << 16;
-       value->value |= 0xff;
-       value->value |= value->value << 8;
+       v = TAB_VALUES_24[i++]; value->value[0] = v | v << 8;
+       v = TAB_VALUES_24[i++]; value->value[1] = v | v << 8;
+       v = TAB_VALUES_24[i];   value->value[2] = v | v << 8;
+                               value->value[3] = 0xffff;
 
        value->vtype = VTYPE_rgba;  /* FIXME */
     }
     else if (value->index - SZT_VALUES < SZT_NONAME_VALUES) {
        i = 3 * value->index;
 
-       value->value  = TAB_NONAME_VALUES_24[i++] << 16;
-       value->value |= TAB_NONAME_VALUES_24[i++] << 16;
-       value->value |= TAB_NONAME_VALUES_24[i] << 16;
-       value->value |= 0xff;
-       value->value |= value->value << 8;
+       v = TAB_NONAME_VALUES_24[i++]; value->value[0] = v | v << 8;
+       v = TAB_NONAME_VALUES_24[i++]; value->value[1] = v | v << 8;
+       v = TAB_NONAME_VALUES_24[i];   value->value[2] = v | v << 8;
+                                      value->value[3] = 0xffff;
 
        value->vtype = VTYPE_rgba;  /* FIXME */
     }
index c70985e7faa9bbb2d418ee3d968e8fbd752668eb..64c1130d1384544c3a3b63662e72892d402f270b 100644 (file)
@@ -22,7 +22,6 @@ extern "C" {
 #endif
 
 typedef int BIT_VTYPE;
-typedef unsigned long VALUE;
 
 typedef enum {
     VTYPE_rgba = 0,
@@ -56,7 +55,7 @@ typedef struct inkpot_values_s {
 typedef struct inkpot_value_s {
     IDX_VALUES index;   /* write by set,  read by get, write by first, read/write by next */
     BIT_VTYPE  vtype;   /*  read by set, write by get,  read by first,       read by next */
-    VALUE      value; /*  read by set, write by get, write by first,      write by next */
+    unsigned short value[4];    /*  read by set, write by get, write by first,      write by next */
 } inkpot_value_t;
 
 extern inkpot_status_t  inkpot_value_set       ( inkpot_values_t *values, inkpot_value_t *value );