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 ...
]]>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.
]]>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)...
]]>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.
]]>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.
]]>I see, thanks!
I just ended up writing directly to the palette_color and not using the set_color() function at all...
]]>...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.
]]>