Re: x color conversion [Was: Re: [AD] minor fix] |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
On Friday 09 July 2004 12:47, Evert Glebbeek wrote:
> Ok, I investigated a bit further and it seems the problem is related to
> the set_color() function. If I change the colour from grey to white in
> line 1037, the GUI shows up normally, but in grey rather than in white. I
> suspect it's a scaling issue between 8 bit and 6 bit RGB values. I'll
take
> a closer look at the code for set_color() if I have time.
Ok, problem solved. The problem was in _xwin_private_set_palette_range and
only appears when X uses BGR instead of RGB ordering.
The set_color() function calls this code with the from and to range equal,
something which the new code did not allow (but could handle fine).
I also fixed a bug that caused the incorrect palette range to be copied
when from was not 0.
I'm going to apply the attached patch.
Evert
--- src/x/xwin.c.orig 2004-07-09 13:23:49.000000000 +0200
+++ src/x/xwin.c 2004-07-09 13:27:59.000000000 +0200
@@ -2001,12 +2001,12 @@
if (_xwin.set_colors != 0) {
if(blitter_func) {
- if(_xwin_use_bgr_palette_hack && ((to-from+1) > 0) && (from >= 0) && (to < 256)) {
+ if(_xwin_use_bgr_palette_hack && (from >= 0) && (to < 256)) {
pal = malloc(sizeof(RGB)*256);
ASSERT(pal);
ASSERT(p);
if(!pal || !p) return; /* ... in shame and disgrace */
- memcpy(&pal[from], p, sizeof(RGB)*(to-from+1));
+ memcpy(&pal[from], &p[from], sizeof(RGB)*(to-from+1));
for (c=from; c<=to; c++) {
temp = pal[c].r;
pal[c].r = pal[c].b;