Various examples always use alloc_color() and stuff like gtk.color.parse('red'), etc. I just do gtk.gdk.Color(65535,0,0), and that seems to work. What's the need for alloc_color
?
views:
56answers:
1
+2
A:
If you're running on a system that uses a palette display (as opposed to a true-colour display), then you must allocate new colours in the palette before you can use them. This is because palette-based displays can only display a limited number of colours at once (usually 256 or sometimes 65536).
Most displays these days are capable of true colour display, which can display all available colours simultaneously, so this won't appear to be a problem and you can get away with directly asking for specific colours.
Greg Hewgill
2009-08-07 02:08:27
does it allocate a best-matching color if run in a 256 or 16-bit color mode?
Claudiu
2009-08-07 02:13:03
(my point is: if it does, I don't see why I have to do it explicitly. If it doesn't - why not? that would clearly be my intention)
Claudiu
2009-08-07 02:13:41
That depends on the particular graphics library. I'm not familiar enough with GTK to say whether `alloc_color()` does any matching.
Greg Hewgill
2009-08-07 02:20:13