|
Fascinating palette behavior... |
SiegeLord
Member #7,827
October 2006
|
RGB rgb = {1,0,0}; set_color(1, &rgb); int col = palette_color[1];//returns 4! I have run into a problem running this code, as you can see I set the first color in the palette to RGB(1,0,0) and then I retreive the value from the current palette. The problem is that instead of returning 1 it returns 4! Is there a bug here or did I do something wrong? Sorry if this has been answered before and feel free to direct me to the manual as appropritate ... "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Fladimir da Gorf
Member #1,565
October 2001
|
IIRC the palette colors have 6-bit resolution, not full 8-bit so maybe that has something to do with it? If you extend the number one from 0...63 to 0...255, youll get 4. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
SiegeLord
Member #7,827
October 2006
|
Hmm... yes, using get_color() does seem to do the trick of retreiving the correct value(I assume it handles the 6 bit calculations on its own)... But that is not viable, since the same happens in my actual program. I write to a 8bpp bmp with this color(#1) and then blit it to a 32bpp and get the pixel color, and also get the incorrect color returned (in this case 4)... "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Fladimir da Gorf
Member #1,565
October 2001
|
That's because it simply can't know what the value used to be. No matter what you pass between 1 and 4, you'll get 4 out - the number resolution is reduced. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
miran
Member #2,407
June 2002
|
Yeah, that's just the way palettes work. It's not a bug and you did nothing wrong. Palette colours are taken from a 6 bit colour space (in each component) so rgb = {1, 0, 0} is actually the same as makecol(4,0,0) in 32bpp. -- |
SiegeLord
Member #7,827
October 2006
|
I see, thanks! I just ended up writing directly to the palette_color and not using the set_color() function at all... "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Kibiz0r
Member #6,203
September 2005
|
...you wouldn't happen to be Siege_Lord of Clan EotA, would you? Edit: I just realized that probably should've been a PM. Waste of server space on me. --- |
|