Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
a690a978
Commit
a690a978
authored
Jun 13, 2011
by
Paul Eggert
Browse files
* xterm.c (x_alloc_nearest_color_1): Go back to original algorithm.
parent
01103c44
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
7 deletions
+5
-7
src/ChangeLog
src/ChangeLog
+1
-3
src/xterm.c
src/xterm.c
+4
-4
No files found.
src/ChangeLog
View file @
a690a978
2011-06-13 Paul Eggert <eggert@cs.ucla.edu>
* xterm.c (x_alloc_nearest_color_1): Use a more-precise algorithm
for nearest color, one that neither overflows nor relies on unsigned
arithmetic.
* xterm.c (x_alloc_nearest_color_1): Prefer int to long when int works.
Remove unnecessary casts.
* xterm.c (x_term_init):
...
...
src/xterm.c
View file @
a690a978
...
...
@@ -1697,7 +1697,7 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
a least-squares matching, which is what X uses for closest
color matching with StaticColor visuals. */
int nearest, i;
int max_color_delta =
(1 << (16 - 2)) - 1
;
int max_color_delta =
255
;
int max_delta = 3 * max_color_delta;
int nearest_delta = max_delta + 1;
int ncells;
...
...
@@ -1705,9 +1705,9 @@ x_alloc_nearest_color_1 (Display *dpy, Colormap cmap, XColor *color)
for (nearest = i = 0; i < ncells; ++i)
{
int dred = (color->red >>
2
) - (cells[i].red >>
2
);
int dgreen = (color->green >>
2
) - (cells[i].green >>
2
);
int dblue = (color->blue >>
2
) - (cells[i].blue >>
2
);
int dred = (color->red >>
8
) - (cells[i].red >>
8
);
int dgreen = (color->green >>
8
) - (cells[i].green >>
8
);
int dblue = (color->blue >>
8
) - (cells[i].blue >>
8
);
int delta = dred * dred + dgreen * dgreen + dblue * dblue;
if (delta < nearest_delta)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment