emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs/src nsterm.m


From: Adrian Robert
Subject: [Emacs-diffs] emacs/src nsterm.m
Date: Tue, 25 Nov 2008 04:39:29 +0000

CVSROOT:        /sources/emacs
Module name:    emacs
Changes by:     Adrian Robert <arobert> 08/11/25 04:39:29

Modified files:
        src            : nsterm.m 

Log message:
        * nsterm.m (ns_get_color): Handle long hex strings (fixes bug #1044).

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/src/nsterm.m?cvsroot=emacs&r1=1.37&r2=1.38

Patches:
Index: nsterm.m
===================================================================
RCS file: /sources/emacs/emacs/src/nsterm.m,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -b -r1.37 -r1.38
--- nsterm.m    25 Nov 2008 04:09:49 -0000      1.37
+++ nsterm.m    25 Nov 2008 04:39:29 -0000      1.38
@@ -1411,13 +1411,22 @@
   /* Direct colors (hex values) */
   if (hex)
     {
-      unsigned int color = 0;
+      unsigned long color = 0;
       if (sscanf (hex, "%x", &color))
         {
-          float f1 = ((color >> 24) & 0xff) / 255.0;
-          float f2 = ((color >> 16) & 0xff) / 255.0;
-          float f3 = ((color >>  8) & 0xff) / 255.0;
-          float f4 = ((color      ) & 0xff) / 255.0;
+          float f1, f2, f3, f4;
+          /* Assume it's either 1 byte or 2 per channel... */
+          if (strlen(hex) > 8) {
+            f1 = ((color >> 48) & 0xffff) / 65535.0;
+            f2 = ((color >> 32) & 0xffff) / 65535.0;
+            f3 = ((color >> 16) & 0xffff) / 65535.0;
+            f4 = ((color      ) & 0xffff) / 65535.0;
+          } else {
+            f1 = ((color >> 24) & 0xff) / 255.0;
+            f2 = ((color >> 16) & 0xff) / 255.0;
+            f3 = ((color >>  8) & 0xff) / 255.0;
+            f4 = ((color      ) & 0xff) / 255.0;
+          }
 
           switch (color_space)
             {




reply via email to

[Prev in Thread] Current Thread [Next in Thread]